Write a Java program and Flowchart that prompts the user to enter two characters and displays the major and status represented in the characters. The first character indicates the major and the second is number character 1, 2, 3, 4, which indicates whether a student is a freshman, sophomore, junior, or senior. Suppose the following characters are used to denote the majors:
I: Information Management
C: Computer Science
A: Accounting
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
//wrong input does not print anything
Scanner sc = new
Scanner(System.in);
System.out.print("Enter the first
character indicates the major: ");
char f = sc.next().charAt(0);
System.out.print("Enter the second
character indicates the student: ");
char s = sc.next().charAt(0);
if(f=='I')
System.out.println("Information
Management");
if(f=='C')
System.out.println(" Computer
Science");
if(f=='A')
System.out.println("Accounting");
if(s=='1')
System.out.println("freshman");
if(s=='2')
System.out.println("sophomore");
if(s=='3')
System.out.println("junior");
if(s=='4')
System.out.println("senior");
}
}
Get Answers For Free
Most questions answered within 1 hours.