CS110 Java Programming Assignment #1

Instructor: Trish Cornez

Naming Variables        Assignment Statements         Using: + , - , / , *

  Instructions - Complete the following before the start of class:
  1. Code, debug, comment, and print the source code for all programs. All programs must contain your name, date, a program message, and code comments. Points will be deducted on programs that are not well coded and commented and pages that are unstapled.
  2. Execute programs three times with different input.
  3. Print the output from all executions (use ALT PrintScreen to capture the output window and then paste into Wordpad or MS Word).

Remember: Assigned work is to be an individual endeavor. Group or shared assignments will receive 0 points. Discussion about assignments should be of a general nature.


Wages are paid at a standard hourly rate for 40 hours per week and at time and one half for overtime. Write a Java program that calculates and displays the weekly pay, given the standard wage amount and the number of hours of overtime as inputs.



Write a program that computes the cost of a pizza. Input for the program should consist of the price (a real number) and the diameter in inches (a real number) of a full pizza. Output should consist of the computed area of the pizza pie and the cost per square inch, in dollars and cents.



Write a Java program that asks the user to enter the price of a car (real), the down payment (real) and the number of years for the loan (integer). Calculate and output the monthly payment (real) of that car. Assume the sales tax rate is 7% and an interest rate is 9%. Use constant declarations for these rates.

Use the following formulae to perform the calculations:
tax amount = price of car * sales tax rate
total cost of car = price of car + tax amount
borrowed amount = total cost of car - down payment
interest amount = borrowed amount * interest rate
loan amount = borrowed amount + interest amount
monthly payment = loan amount / number of months of loan



Write a program that prompts the user for two integers and then displays the sum, the difference, the product, the average, the absolute value of the difference, the larger of the two, and the smaller of the two. Hint: The Math class contains max and min functions.


If you are like most people, you collect a fair amount of change in your pocket. A painless savings plan is to dump all the loose change into a jar at the end of the week. However, we'd like some idea of the mount of money we'll have saved in a year so we can start thinking about what we want to buy.

In the this exercise you will write a Java probram to estimate the yearly savings based on the amount of change saved at the end of four weeks.
NOTE: It is important in this program that you analyze and limit your memory allocations - variable declarations. Efficiency can often mean recycling variables.

The amount of change saved at the end of each week will be recorded as four numbers: the number of pennies, nickels, dimes, and quarters.
Here is an example of the input and output behavior of the program:

Enter the number of pennies, nickels, dimes, and quarters saved at the end of Week 1. Enter after each number:
Enter the number of pennies, nickels, dimes, and quarters saved at the end of Week 2. Enter after each number:
Enter the number of pennies, nickels, dimes, and quarters saved at the end of Week 3. Enter after each number:
Enter the number of pennies, nickels, dimes, and quarters saved at the end of Week 4. Enter after each number:

Over four weeks you have collected 25 Pennies, 12 Nickel(s), 21 Dime(s), and 17 Quarter(s).
This comes to $7 .20
Your weekly average is $1.80.
Your estimated yearly savings is $93.60
This program will require the use of constants!