Please keep it simple; just structural programming.. no need for private nor dif
ID: 3779625 • Letter: P
Question
Please keep it simple; just structural programming.. no need for private nor different classes. As simple as you can!!
Thank You!
ITP 120 Program 3 You are to prompt the user for a 3-digit ID and a birth date for each college student. For the birth date, prompt for 3 integers in the order month, day, and year. Be sure to validate the birth date (for the year, it must be in the 1900's. Don't worry about validating if it's a leap year). The last student ID will be 000. You are to output the ID and birth date for each student. The birth date should be output in the format February 15, 1982. Also, output how many students were processed, how many of the students had a February 29th birth date, and the birth date of the oldest student. Be sure to use good programming style. Object-oriented programming techniques are to be used. You are to submit a secure folder containing the following: 1. A hard copy of your class description and pseudocode. A hard copy of your source code. 3. Your flash drive which contains your source code. Be ure your name is on the outside of your flash drive. 4. Your executable class and file are to be named StudentBirthdate. The folder is to be named Program 3Explanation / Answer
Program:
import java.util.Scanner;
public class StudentDetails {
public static void main(String str[]){
String [] monthlist= new String[]{"January", "February", "March", "April",
"May", "June", "July", "August", "September",
"October", "November", "December"};
Scanner sca = new Scanner(System.in);
int [] studentId = new int[100];
int [] day = new int[100];
int [] month = new int[100];
int [] year = new int[100];
int i=-1;
int count=0;
do{
i++;
System.out.print("Enter Student id : ");
studentId[i] = sca.nextInt();
System.out.print("Enter Month : ");
month[i] = sca.nextInt();
System.out.print("Enter Day : ");
day[i] = sca.nextInt();
System.out.print("Enter Year : ");
year[i] = sca.nextInt();
}while(studentId[i]!=000);
System.out.println(" Student Id Student Birthdate");
for(int j=0;j<=i;j++){
System.out.print(" "+studentId[j]+" "+monthlist[month[j]-1]+" "+day[j]+", "+year[j]+" ");
if(day[j]==29 && month[j]==2){
count++;
}
}
System.out.println(" Total No of student processed : "+(i+1));
System.out.println("Total No of student whose birthdate is Feb 29th : "+ count);
}
}
Result:
Enter Student id : 100
Enter Month : 2
Enter Day : 29
Enter Year : 1999
Enter Student id : 101
Enter Month : 2
Enter Day : 29
Enter Year : 1977
Enter Student id : 102
Enter Month : 3
Enter Day : 24
Enter Year : 1987
Enter Student id : 000
Enter Month : 3
Enter Day : 5
Enter Year : 1998
Student Id Student Birthdate
100 February 29, 1999
101 February 29, 1977
102 March 24, 1987
0 March 5, 1998
Total No of student processed : 4
Total No of student whose birthdate is Feb 29th : 2