APCS Unit 1 (Java Basics) Programs:
Project 1: Write a program to simulate a cash register purchase of one item. You will need to ask the user for the price of the item they wish to purchase. You will then calculate the tax on that purchase and the final cost (declare the tax rate as a constant value of 0.0725). The run of the program and the output should look something like the following:
Here is a sample run of this program:
What is the price of the item? 24.95
Here is your receipt:
Price: 24.95
Tax: 1.80887
Total Cost: 26.7589
Use the above as test data for your program.
Project 2: Write a program which will enable the user to determine the net pay amount of their paycheck based on the number of hours they worked. Assume that they are paid on an hourly basis and that the hourly rate is declared as a constant (12.75). You will also need to deduct taxes from their check. Assume that 25% of their pay goes to taxes and declare that percentage as a constant.
Here is a sample run of this program:
How many hours did you work this week? 35
Here is your pay stub:
Hours Worked: 35
Hourly Wage: 12.75
Gross Pay: 446.25
Taxes Deducted: 111.563
Net Pay: 334.688
Project 3: Write a program that accepts 3 numbers representing yards, feet and inches. It should then convert them into total inches.
Sample run of the program:
How many yards? 1
How many feet? 2
How many inches? 3
All together, you have 63 inches.
Project 4: Now write a program that accepts an integer representing total inches and then converts that into the appropriate number of yards, feet and inches.
Sample run of the program:
How many total inches? 137
3 yards
2 feet
5 inches
Also try the following:
84 total inches = 2 yards, 1 feet and 0 inches
32 total inches = 0 yards, 2 feet and 8 inches
Project 5: Write a program that will accept an amount of change less than a dollar. It will then determine and output the best change for a dollar. An example is given below.
Sample Run of the Program:
Enter the change amount: 64
Quarters: 2
Dimes: 1
Nickels: 0
Pennies: 4
Project 6: A certain bacteria grows according to the model P = I*(1.4)^t where I is the initial population, t is time in days, P is the population at time t. Write a program which will allow you to input the initial population of bacteria and a number of days. The program will then output the current population at the end of that number of days.
Sample run of the program:
Initial population: 50
Number of days: 5
After 5 days, the population grows from 50 to 268
Project 7: The distance between two points, (x1,y1) and (x2, y2) is found by the formula
Write a program that prompts the user to enter coordinates for two points and then determines the distance between them. Round answer to one decimal place.
Sample run of the program:
Enter x1: 3
Enter y1: -2
Enter x2: -1
Enter y2: 5
Distance = 8.1
Project 8:
Write a program that accepts a date in the format: Month Day, Year (i.e. September 3, 2013) and displays the date in the format (9-3-2013)
Hint: Use methods of the String class such as .length, .indexOf, .substring
What day do you want to convert? May 10, 2001
The date is: 5-10-2001
Project 9:
Write a method that prints the two double roots (solutions) for a quadratic with integer parameters a, b, and c. Use a temporary variable to hold in order not to compute it twice.
public void printRoots(int a, int b, int c)