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
Help me out on question 29 and 30 please
Elanso [62]

Answer:

It 5

Explain

number 28 is A and number 29 is 5

5 0
2 years ago
Type the correct answer in the box. Spell the words correctly.
ExtremeBDS [4]

Answer:

The IT field yeah am sure

7 0
3 years ago
A restaurant buys a pizza oven that is 4.5 feet long, 5 feet wide and 6 feet tall. What is the volume of the pizza oven?
torisob [31]

Answer:

135 as 4.5 times 5 times 6 gives you the volume and it =135

4 0
2 years ago
Which of the following statements best describes IT careers?
DiKsa [7]

The answer is (C) IT careers are found in a wide variety of industries.

Nowadays, all types of industries in various different parts of the world will have an IT (information technology) department because it is needed, since most businesses operate using some form of IT equipment, which, most commonly found is a computer. It is a particularly lucrative field because of the wide array of job availability.

7 0
3 years ago
A file type that allows a document to be read on most computers is a _____.
Travka [436]
Txt

Note, only Windows really cares about the file extension. OSX's Finder will use it if Finder can't find a creator in the file metadata to select an app when double clicking on it. Linux and Unix don't care.
7 0
3 years ago
Other questions:
  • A browser is used for creating Web pages. true or false?
    5·2 answers
  • What is earning potential?
    10·1 answer
  • All computers perform disk optimization utilizing the same software.<br><br> true <br> false
    11·1 answer
  • Which logic gate produces an output of 1 only if both its inputs are 0
    12·2 answers
  • How does the system work for this:
    15·2 answers
  • How can a search be narrowed to only search a particular website????
    15·1 answer
  • What are the different Stape of data processing cycle?​
    8·1 answer
  • Select statements about Multiprocessors that are FALSE. a. Asymmetric multiprocessors are a popular form of tightly coupled arch
    7·1 answer
  • Which term best describes these lines?
    7·1 answer
  • What is the value of six sigma ? How dose it relate to agile management
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!