time due | submission file |
---|---|
11:00 PM Wednesday 12 September, 2007 | csci/201/Homework2 |
At exactly 11:00 PM, on Wednesday, 12 September, 2007, a program will be run to copy your homework out of your csci/201/Homework2 directory on the UNCA Computer Science server. Your homework must be stored in this directory exactly as specified a bit later in this handout in order to be copied. Programs that are not stored correctly will not be graded and will be considered unsubmitted.
At 11:00 PM on each of the three days following 12 September, additional attempts will be made to copy programs that are submitted late. There is a penalty of 15% for each day a program is submitted late.
Create a NetBeans project called Homework2
to solve
this problem. Use NetBeans' defaults in creating your
project just as was done in the first week's lab.
This program will solve the problem of making change. Like most programs, it will: (1) receive input, (2) do calculations, and (3) generate output.
The program will receive one double number as input. It will prompt the user to enter the required number by printing the following statement to the monitor:
Please enter the amount of money in dollars to be converted to coins:
(Note that an input of 1.23, represents one dollar and 23 cents.) The program should then read the number that the user enters using the
Scanner
class.
This program will convert the dollar amount input by the user to an equivalent number of coins using the smallest number of coins possible. For example, an input of 1.23 would be converted to: 4 quarters, 2 dimes, and 3 pennies as opposed to 123 pennies. You will use the numeric operators discussed in class to do this calculation.
The output of your program should be as follows for an input of 1.23:
1.23 dollars is equivalent to: 4 quarters 2 dimes 0 nickles 3 pennies
As a second example, the output for an input of 0.15 would be:
0.15 dollars is equivalent to: 0 quarters 1 dimes 1 nickles 0 pennies
Oh yes, there's one more thing. In this program you also need to be aware of good programming style. There are two aspects of style that we will focus on: (1) comments, and (2) indentation.
You should beginn your program with comments that identify the author and purpose of the program such as those shown below:
/* * Author: George Bush * Purpose: To calculate equivalent change for an input dollar value. */
The indentation of each line in your program should be consistent with the block structure of that program. Each line of code should be consistently indented from the enclosing brackets as shown below:
public static void main(String[] args) { // TODO code application logic here System.out.println("Give me a number to be squared"); Scanner stdin = new Scanner(System.in); int inNumber = stdin.nextInt(); System.out.println("The square is " + inNumber*inNumber); }
Your completed program must be stored within
a subdirectory
csci/201/Homework2 of your Linux home
directory. If you create a project named Homework2
at project location csci/201 as was done in
the first week's lab this will happen automatically.
If you complete this assignment on your "home" system,
you still must:
(1) create a Homework2
projects;
(2) accept the defaults when creating your project thus
creating a program with a Main
class within
the homework2
package;
(3) create a csci/201/Homework2
directory within your Linux account to store your work; and
(4) copy the src/homework2/Main.java
of your Homework2
project at home into your
csci/201/Homework2 directory at UNCA.