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
What is your understanding about the subject “digital image processing”?
N76 [4]

Answer:

Here's your answer mate.....☺️☺️

Explanation:

In computer science, digital image processing is the use of a digital computer to process digital images through an algorithm. ... It allows a much wider range of algorithms to be applied to the input data and can avoid problems such as the build-up of noise and distortion during processing.

<em><u>Hope it helps </u></em>☺️

5 0
3 years ago
After installing an update on her MacBook, a user contacts the technician to complain that the WiFi is not working. The WiFi ico
GarryVolchara [31]

Answer:

The correct answer to the following question will be "PRAM needs to be reset".

Explanation:

<u>PRAM:</u>

  • It is commonly known as "Parameter Random Access Memory". It is a memory that is used to store the settings of the system of a Mac OS. These settings comprise of monitor settings, speaking settings, WI-FI settings, etc.
  • So, according to the given case when the WI-FI icon shows that the system is connected to the internet but he is not able to browse the internet. In this case, he needs to reset the PRAM to browse the internet.

So that the above is the right answer.

4 0
3 years ago
One type of CAPTCHA is ________. a rootkit virus the wavy hard-to-read letter and number sequence that you type to prove that yo
sergejj [24]
<h2>password method</h2>

Explanation:

Rootkit virus is one type of virus which is hidden about its existence and tries to affect the maximum number of system.

Password method: This is a graphical method to identify the text hidden in the signature and confirming that it is not a robot or any other system to protect the system from hacking. This would be really hard-to-read and thus ensures safety.

Antivirus software: This is a system to protect the system, when the virus tries to attack the system. An indication will be given through the software to the user.

4 0
3 years ago
The computers in the administrative offices of the four schools throughout the district are networked to enable employees to acc
muminat
These computers in administrative offices or schools throughout the district that are networked to each other has the type of network most likely used by the workers is LAN network. Usually LAN networks are used in small offices or rooms.
3 0
3 years ago
If we were to replicate Dr. Stanley Milgram's obedience study today, do you think the results would be different?
Montano1993 [528]

Answer:

Explanation:

The results would be exactly the same. We have learned little about authority and when to oppose it.

I'll give you an example. Last night I was in a restaurant like Taco Bell or Subway. Across from me was a girl with an ordinary backpack which was all I could see. It was quite common to see that in the University District where I was. I paid no attention until two policemen came in (both over 200 pounds -- she was tall but could not have been more than 130) and began arrest procedures. She started shouting very foul language but otherwise did not resist. They put handcuffs on her wrists which were behind her back. Again she she  used profane language only screaming that they were hurting her. It took the one police officers a moment to find his key and loosen the cuffs, which he did, but she was still uncomfortable and cursing.  

She was silent as they took her out. Nobody questioned the incident at all. Do you think Dr. Millgram would recognize this as an example of his theory? I'm sure he would. Trust me, this was not staged. There was a 3rd officer who drove the girl and one of the 2 arresting officers away.

7 0
2 years ago
Other questions:
  • What are some of the challenges that could arise from setting up a file management system on a computer?
    11·1 answer
  • Which keys should you press to insert a comment? Ctrl+Alt+I Ctrl+Alt+C Ctrl+Alt+O Ctrl+Alt+N Ctrl+Alt+M
    15·1 answer
  • Drag each tile to the correct box.
    8·2 answers
  • Review universal data models and discuss how these are being used more widely today. Does a data modeling project using a packag
    9·2 answers
  • 3) How ash traditional technology and modern
    10·1 answer
  • Which is the most popular language used in game programming?
    5·2 answers
  • When an external device becomes ready to be serviced by the processor the device sends a(n)_________ signal to the processor.
    8·1 answer
  • What is an issue with using cloud computing?
    15·1 answer
  • owever, sitting in a corner of the store, a hacker had just set up an open "rogue" wireless hotspot posing as the coffee shop’s
    7·1 answer
  • to troubleshoot an output component or input device, the first step is to activate the input device that controls the first outp
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!