Question: Question 1.A. Write a java program that uses a Scanner object to read in user input. The program asks the user for number between 1

Question 1.A. Write a java program that uses a Scanner object to read in user input. The program asks the user for number between 1 and 100. If the number is between 1 and 50 it prints You are in the first half and if the number is greater than 50 it prints You are in the second half.

Sample outputs:

//Prints the first half

Input a number between 1 and 100: 25

You are in the first half.

//Prints the second half

Input a number between 1 and 100: 55

You are in the second half.

Provide:

Printout of Properly Formatted Source Code

Example output/test cases (2 test cases different than above that show both cases).

Question 1.B.

Write a program that uses a Scanner object to read in user input. The program will determine if a user gets a discount for a bus ticket. First ask the user to enter the regular price of a bus ticket. Then ask the user if they are a student (note, the Scanner class has a nextBoolean method to read in boolean values). If they are a student, they get a 15% discount on the price of the ticket. Print the original price, what the discount is (if any) and the new price of the ticket. You need to control for the decimal point to two decimal places. You can control the output of the decimal place by using the printf statement (see the end of this assignment for a description).

Sample outputs:

//student is true

Question 1.A. Write a java program that uses a Scanner object to

//student is false

read in user input. The program asks the user for number between

Provide:

Printout of Properly Formatted Source Code

Example output/test cases (2 test cases different than above that show both cases).

Make sure it is done in Java format.

r-jGRASP exec: java A1_BusTicket Enter the price of the bus ticket: 12 Are you a student (true or false)? true The price of the ticket is $12.00 The discount for the ticket is $1.80 The total cost is $10.20 )GRASP : operation complete

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!