Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

//student is false

image text in transcribed

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

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

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions

Question

Use internal communication to shine

Answered: 1 week ago

Question

What are the need and importance of training ?

Answered: 1 week ago

Question

What is job rotation ?

Answered: 1 week ago

Question

5. Discuss the role of the Web in career management.

Answered: 1 week ago

Question

4. Design a career management system.

Answered: 1 week ago