HW 02: Tip Calculator + Tense Corrector Solved

25.00 $

Category:

Description

HW 02: Tip Calculator + Tense Corrector Solved
5 (100%) 1 vote[s]

Goals:

  • Familiarity with primitive data types
  • Perform ​arithmetic operations on numeric data Manipulate strings using the Java String library ● Getting inputs and printing outputs using ​Scanner​.

 

Prerequisites:

  • Knowledge on string manipulation.
  • Knowledge on getting inputs and printing outputs using ​Scanner​.

 

Description:

For your second homework assignment you are required to write two separate Java programs, ​TipCalculator.java​ ​and​ ​TenseCorrector.java​, ​that will prompt users to provide certain information which the program will process and produce an output according to its functions respectively.

  1. Task 1: Tip Calculator​
  2. Task 2: ​Tense Corrector

 

Task 1: Tip Calculator

This program uses the Scanner class to prompt users for an amount to be paid by the user in US dollars (a ​double​) and the percentage of tip the user is willing to give (an ​int​). The base amount (a ​double​), tip amount alone (a ​double​), and the total amount to be paid (a double​) should then be produced as an output on the console as shown on the example below. It is important to follow the format closely.

 

Example/Demonstration:

 

Price($): 200

Tip Percentage(%): ​ ​15

 

Price Without Tip($): 200.00

Tip Amount($): 30.00

Total Amount($): 230.00

 

 

Task 2: Tense Corrector

This program uses the Scanner class to prompt users for a sentence with possible grammatical errors in it (a String). The program will then manipulate the given string by replacing all the words in the table below into their past tense. You will only be checked for the successful conversion of these given words. The “corrected” sentence (a String) will then be displayed on the console in the next line as shown below.

 

Purdue University                                                                        Problem Solving And Object-Oriented Programming

CS 18000

 

 

“Incorrect” Words “Corrected” Words
Is Was
Am Was
Are Were
Do Did

 

 

Example/Demonstration:

 

Original Sentence:​ ​It is a holiday

Corrected Sentence: It was a holiday(Corrected)

Original Sentence: I am confused but they are not Corrected Sentence: I was confused but they were

not(Corrected)

Original Sentence: We do not understand

Corrected Sentence: We did not understand(Corrected)