Description
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
CS 18000
Problem Solving And Object-Oriented Programming
“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)
Turning in Your Work
Submit your files, TipCalculator.java and TenseCorrector.java, to Vocareum
through Blackboard. Keep in mind that only your last submission will be considered.
Grading Rubric — 100 points
– Tip Calculator — 50 points total
– (10 points) Prompts the user for price amount (a double)
– (10 points) Prompts the user for tip percentage (an int)
– (10 points) Prints the correct amount for price amount(a double) in the correct
format
– (10 points) Prints the correct amount for tip amount(a double) in the correct format
– (10 points) Prints the correct amount for total amount(a double) in the correct
format
– Tense Calculator — 50 points total
– (10 points) Prompts the user for original sentence (a String)
– (10 points) Successfully concatenates corrected sentence with “(Corrected)” and
prints them in the correct format
– (30 points) Successfully corrects the words “Is”, “Am”, “Are” and “Do” and prints
corrected sentence in the correct format