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
Which of the following events would most likely produce an earthquake
sveticcg [70]

Earthquakes are usually caused when rock underground suddenly breaks along a fault. This sudden release of energy causes the seismic waves that make the ground shake. When two blocks of rock or two plates are rubbing against each other, they stick a little. ... When the rocks break, the earthquake occurs.

8 0
3 years ago
Suppose an IP packet is fragmented into 10 fragments, each with a 1% (independent) probability of loss. To a reasonable approxim
Marysya12 [62]

Answer:

a. 0.01

b. 0.001

c. The identification field of the packet fragment can be used to uniquely identify and collate the fragments lost in transmission.

Explanation:

The probability of losing a packet is 10% or 0.1, so the probability of losing the packet twice during transmission;

= 0.1 x 0.1 = 0.01

When any fragments have been part of the transmission, the probability of the packet is dependent on the fragments;

= 0.01 x 0.1 = 0.001

The identification field is a unique 16-bit value assigned to an IPv4 packet, when a packet is fragmented for transmission, its field is used to collate the unique fragments in the packet.

6 0
2 years ago
How to shutdown a computer by step by step​
Reptile [31]

<u><em> </em></u>Answer:

1) Press Ctrl + Alt + Del

2) Click the power button in the bottom-right corner of the screen.

3) From the desktop, press Alt + F4 to get the Shut Down Windows screen.

and that's how to shut down your computer

<u><em></em></u>

<u><em>Please mark as brainliest if answer is right</em></u>

Have a great day, be safe and healthy  

Thank u  

XD  

7 0
2 years ago
Read 2 more answers
P1 has a clock rate of 4 GHz, average CPI of 0.9, and requires the execution of 5.0E9 instructions.P2 has a clock rate of 3 GHz,
nadezda [96]

Answer:

Following is attached the solution for all parts. I hope it will help you!

Explanation:

7 0
3 years ago
What does tech mean in technology?
g100num [7]

Answer:

abbreviation for technical or technological

3 0
3 years ago
Read 2 more answers
Other questions:
  • Array A is not a heap. Clearly explain why does above tree not a heap? b) Using build heap procedure discussed in the class, con
    15·1 answer
  • What is the solubility of an empty soda can
    10·1 answer
  • Help me pleseeeeee i will mark u as brainliest
    10·1 answer
  • Suppose there are two links between a source and a destination. The first link has transmission rate 100 Mbps and the second lin
    12·1 answer
  • What is one reason why a business may want to move entirely online?
    13·1 answer
  • What are the consequences of plagiarism?
    7·2 answers
  • Name three types of hard drives, along with its speed and size.
    8·1 answer
  • several ways that we commonly use technology today that people couldn't 10 years ago. Are these uses helpful or harmful to socie
    9·1 answer
  • Drag the tiles to the correct boxes to complete the pairs.
    6·1 answer
  • In Windows, what does the device manager tell you?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!