Write a java program that makes use of the ‘DO WHILE ’ loop. The program asks a user to enter information about several of their friends. The information is their last name, the state they live in, their age, and their expected graduation year. After you enter one friend, write out each individually. You must use JOptionPane to input the 4 fields, and to output the 4 fields. Refer to the textbook Code Listing 4-6 to see how to use ‘char repeat’ to terminate the do while loop.
Hi,
Please find the java program below:
-------------------------------------
Java Classes:
// class used to store friend information
public class Friend {
private String lastName;
private String state;
private int age;
private int graduationYear;
//Constructor
public Friend(String lastName, String state, int age,
int graduationYear) {
super();
this.lastName = lastName;
this.state = state;
this.age = age;
this.graduationYear =
graduationYear;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getGraduationYear() {
return graduationYear;
}
public void setGraduationYear(int graduationYear)
{
this.graduationYear =
graduationYear;
}
}
///////////////////////////////////////////////////////////////
import java.util.Scanner;
import javax.swing.JOptionPane;
public class MainProgram {
/**
* @param args
*/
public static void main(String[] args) {
int age;
int year;
String name;
String state;
char repeat;
Scanner keyboard= new
Scanner(System.in);
String userInput;
do{
name =
JOptionPane.showInputDialog("Please input lastname:");
state =
JOptionPane.showInputDialog("Please input state:");
age =
Integer.parseInt(JOptionPane.showInputDialog("Please input
age:"));
year =
Integer.parseInt(JOptionPane.showInputDialog("Please input
graduation year:"));
Friend f= new Friend(name,state,age,year);
System.out.println("##########Friend
Information############");
System.out.println("Last Name :=" +
f.getLastName());
System.out.println("State
:=" + f.getState());
System.out.println("Age
:=" + f.getAge());
System.out.println("GraduationYear :=" +
f.getGraduationYear());
System.out.println("######################");
System.out.println("Would you like to input another friend
information?");
userInput=
keyboard.nextLine();
repeat=
userInput.charAt(0);
}while(repeat == 'Y' || repeat ==
'y');
}
}
Screenshot:

------------------------------------------------------------------
Let me know if you need more information on this in the
comments.
Hope this helps.
Write a java program that makes use of the ‘DO WHILE ’ loop. The program asks...
.Need code for my java class !! Write a simple java program that uses loops. You may use ‘WHILE’ or ‘FOR’ or ‘DO-WHILE’ – you decide. The program should use a loop to compute the semester average for up to 5 students. In the loop the user will ask for a student name and their 3 test scores and add them up and divide the total by 3 giving the semester average. You will print out the student name and...
java program
QUESTION 2: 1. Write a do-while loop that asks the user to select a task from the following menu to continue: 1. Option 1 2. Option 2 3. Option 3 4. Option 4 5. Exit Read the selection from the keyboard then write the switch statement: For option 1, display the message "Do the option 1" For option 2, display the message "Do the option 2" For option 3, display the message "Do the option 3" For option...
USE JAVA. Just a basic code. We these in Blue J
2) Write a while loop that lets the user enter a number. The number should be multiplied by 10 and the result stored in the variable product. The loop should iterate as long as product contains a value less than 100. 3) Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The user should be asked if...
Java Letter Counter: Write a program that asks the user to enter a string, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the string. Must use a do while loop and a counter!!!!
HELP IN JAVA: WHILE LOOP: Write a program that asks the user to enter a number of seconds. This number should be less than or equal to 32767 because that is the largest number pep8 can handle. Your program should then output the number of hours, minutes, and seconds on the planet of Crypton, where there are 64 seconds in a minute and 32 minutes in an hour.
Design a Do-While loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop should ask the user whether he or she wishes to perform the operation again. If so, the loop should repeat; otherwise it should terminate. using visual basic
In Java, write a program using a loop that asks the user to enter a series of decimal numbers. The user must enter -88 to end the input of the decimal numbers. After the user enters all numbers, the program should display the sum of all numbers entered.
python program 6 Write an input validation loop that asks the user to enter a number in the range of 100 through 1000? 7 Write an input validation loop that asks the user to enter ‘Y’, ‘y’, ‘N’, or ‘n’? 8 How many times the following loop will repeat? cnt = 0 while cnt != 5: print(cnt) cnt = cnt + 2
2. Write a java program that asks you to enter your last name, your country of origin, your age, and your expected graduation year. After you enter them, write out each answer on a separate line. You must use Scanner to input the 4 fields, and println to output the 4 fields separately.
Write a single program in java using only do/while loops for counters(do not use array pls) for the majority of the program and that asks a user to enter a integer and also asks if you have any more input (yes or no) after each input if yes cycle again, if not the program must do all the following 4 things at the end of the program once the user is finished inputting all inputs... a.The smallest and largest of...