1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
stellarik [79]
3 years ago
15

Write a program that prompts the user to enter two characters and display the corresponding major and year status. The first cha

racter indicates the major. And the second character is a number character 1, 2, 3, 4, which indicates whether a student is a freshman, sophomore, junior, or senior. We consider only the following majors:
B (or b): Biology

C (or c): Computer Science

I (or i): Information Technology and Systems

Note that your program needs to let the user know if the major or year is invalid. Also, your program should be case-insensitive: your program should tell "Biology" either user type ‘b’ or ‘B’.

Here are three sample runs:

Sample 1:

Enter two characters: i3

Information Technology and Systems

Junior

Sample 2:

Enter two characters: B5

Biology

Invalid year status

Sample 3:

Enter two characters: t2

Invalid major

Sophomore

What to deliver?

Your .java file including:

1. (Code: 5 points, Comments: 3 points) Your code with other appropriate comments.

2. (2 points) Four sample runs with the following four input:
(1) i3

(2) T2

(3) c2

(4) F0

Note that you need to run your program 4 times. Each time you run it, copy and paste the program output to the top of your program. After you finished these 4 runs, comment out the output you pasted so that you program would continue to run without any issue.
Computers and Technology
1 answer:
nydimaria [60]3 years ago
4 0

Answer:

  1. import java.util.Scanner;  
  2. public class Main {
  3.    public static void main(String[] args) {
  4.        Scanner input = new Scanner(System.in);
  5.        System.out.print("Please enter two characters: ");
  6.        String inputStr = input.nextLine();
  7.        if(inputStr.charAt(0) == 'B' || inputStr.charAt(0) == 'b'){
  8.            System.out.println("Biology");
  9.        }
  10.        else if(inputStr.charAt(0) == 'C' || inputStr.charAt(0)== 'c'){
  11.            System.out.println("Computer Science");
  12.        }
  13.        else if(inputStr.charAt(0) == 'I' || inputStr.charAt(0) == 'i')
  14.        {
  15.            System.out.println("Information Technology and Systems");
  16.        }
  17.        else{
  18.            System.out.println("Invalid major");
  19.        }
  20.        int num = Character.getNumericValue(inputStr.charAt(1));
  21.        if(num >= 1 && num <= 4){
  22.            switch (num){
  23.                case 1:
  24.                    System.out.println("freshman");
  25.                    break;
  26.                case 2:
  27.                    System.out.println("sophomore");
  28.                    break;
  29.                case 3:
  30.                    System.out.println("junior");
  31.                    break;
  32.                case 4:
  33.                    System.out.println("senior");
  34.                    break;
  35.            }
  36.        }
  37.        else{
  38.            System.out.println("Invalid year status");
  39.        }
  40.    }
  41. }

Explanation:

The code consists of two main parts. The part 1 is to validate the input major and print out the major according to the input character (Line 10 -22). If the input character is not matched with the target letters, a message invalid major will be displayed.

The part 2 is to validate the year status to make sure it only fall within the range of 1-4  (Line 26 -45). If within the range, the program will display the year major accordingly. If not a message invalid year status will be displayed.

You might be interested in
Convert each of the fo" wing base ten representations to its equivalent binary form a. 6 b. 13 C. d. 18 e. 27
asambeis [7]

Answer:

6=110

13=1101

18=10010

27=11011

Explanation:

A decimal number is converted to binary number by constantly dividing the decimal number by 2 till the number becomes zero and then write the remainders in reverse order of obtaining them.Then we will get our binary number.

I will provide you 1 example:-

18/2 = 9   the  remainder =0

9/2 = 4    the remainder =1

4/2 = 2    the remainder =0

2/2 = 1     the remainder =0

1/2 = 0     the remainder =1

Writing the remainder in reverse order 10010 hence it is the binary equivalent of 18.

6 0
3 years ago
It is considered good practice to save a presentation before printing it. true false
Ilya [14]
It is true because it is really a good practise to save a presentation before printing it

5 0
2 years ago
Which of the following is a safe work practice to protect you from electrocution hazards?
Flura [38]
What are the answer choices?
7 0
3 years ago
If a node has a wireless connection to the internet, does that node have to be mobile
Marizza181 [45]
No it does not . answers
8 0
3 years ago
In​ 1972, gordon bell formulated​ bell's law, which states​ ________.
Masja [62]

I guess the best option is letter D.

In 1972, Gordon Bell formulated Bell's Law, which states a new computer class forms roughly each decade establishing a new industry.

4 0
3 years ago
Other questions:
  • An is auditor reviewing a network log discovers that an employee ran elevated commands on his/her pc by invoking the task schedu
    10·1 answer
  • ____ refers to data, applications, and even resources stored on computers accessed over the Internet. Answer
    5·1 answer
  • How do you put a picture when you ask a question?
    6·2 answers
  • ________ is used by text recognition software to convert typed, printed, or handwritten text into the computer-based characters
    15·1 answer
  • " In which software generation did the distinction between systems programmers and other programmers first surface?"
    15·1 answer
  • A(n) _____ is a firm that delivers a software application, or access to an application, by charging a usage or subscription fee.
    6·1 answer
  • Where do charts get the data series names?
    14·1 answer
  • Question 7 (True/False Worth 3 points)
    8·2 answers
  • Challenge activity 1.11.1: using constant in expression is not working for me. Can any one help me find the right code?
    12·1 answer
  • What impact download speeds on different computers
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!