Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in Java that asks the user to enter one of the following streams: science, commerce, or arts. Based on the user's choice,

Write a program in Java that asks the user to enter one of the following streams:
science, commerce, or arts. Based on the user's choice, the program should print the
courses available in that stream. The program should use conditional statements to
determine which courses are available, and it should use the toLowerCase() method
to convert the user input to lowercase so that it can match the even if the user
enters the stream in uppercase or mixed case letters. If the user enters an invalid
stream, the program should print an error message.
Import the required packages, such as the java.util.Scanner package, which
will be used to take input from the user.
Create a new Scanner object to read the user's input.
Prompt the user to enter one of the streams: science, commerce, or arts.
Read the user's input and store it in a string variable.
Use the toLowerCase() method to convert the user's input to lowercase.
Use conditional statements to determine which courses are available based on
the user's input.
print an error message indicating that the user has entered an invalid stream.
Close the Scanner object to release any resources it is using.
Run the program and test it by entering various streams (in uppercase,
lowercase, or mixed case) and checking if the correct courses are printed.
OUTPUT:
For the commerce stream, the following courses are available in first year:
Accountancy
Business Studies
Economics
Entrepreneurship
>|
Invalid stream. Please enter a valid stream (science, commerce, arts)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

Recognize and describe the steps in the recruiting process

Answered: 1 week ago

Question

Appreciate the contribution made by a positions incumbent

Answered: 1 week ago

Question

Know how to conduct a position analysis

Answered: 1 week ago