Java using NetBean
Write a program to display your information in a message dialog window as following: Your name Your major Your email address Note: you can use “\n” in message to break a line.
//TestCode.java import javax.swing.*; import java.util.Scanner; public class TestCode { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter name: "); String name = scanner.nextLine(); System.out.print("Enter major: "); String major = scanner.nextLine(); System.out.print("Enter email: "); String email = scanner.nextLine(); String res = "Your name: "+name+"\nYour major: "+(major)+"\nYour email address: "+email+"\n"; JOptionPane.showMessageDialog(null, res); } }
Get Answers For Free
Most questions answered within 1 hours.