CSE110 Assignment #1 Solved

35.00 $

Category:

Description

Rate this product

Topics

  • Variables: declaration and value updates
  • Arithmetic Expressions (+, -, /, *, %)
  • Using Scanner class to get the input from the user

    Use the following Guidelines:

 

  • ï‚·  Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc).
  • ï‚·  Keep identifiers to a reasonably short length.
  • ï‚·  User upper case for constants. Use title case (first letter is upper case) for classes. Use lower

    case with uppercase word separators for all other identifiers (variables, methods, objects).

  • ï‚·  Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes

    classes, methods, and code associated with ifs, switches and loops. Be consistent with the

    number of spaces or tabs that you use to indent.

  • ï‚·  Use white space to make your program more readable.

    Important Note:

    All submitted assignments must begin with the descriptive comment block. To avoid losing trivial points, make sure this comment header is included in every assignment you submit, and that it is updated accordingly from assignment to assignment.

    Your programming assignments require individual work and effort to be of any benefit. Every student must work independently on his or her assignments. This means that every student must ensure that neither a soft copy nor a hard copy of their work gets into the hands of another student. Sharing your assignments with others in any way is NOT permitted. Violations of the University Academic Integrity policy will not be ignored. The university academic integrity policy is found at http://www.asu.edu/studentlife/judicial/integrity.html

 

Maximum points: 20 pts

Part 1: Explain the solution in your words. (5 Pts)

This assignment has two parts. The first part (Part 1) is to write the solution briefly in your words. It is not a coding question but English writing question. Do not spend a whole page for each question. Try to explain each solution within 150 words.
The second part (Part 2) is to make a program to display the expected result(s) from user input. It is up to you to start from Part 1 or Part 2. In my case, I start the Part 2, and then answer the Part 1 after my program works correctly.

Note: The answers should be typed in the block of comments in the Assignment1.java file after your header such as;

//*********************************************************** // Name: Your name here
// Title: AssignmentX.java
// Description: Short description should be typed here.

// Date: mm/dd/yyyy //***********************************************************
/*
Question 1) First, The amount of cents is converted into … …

Question 2) First, The amount of seconds is converted into … …
*/

Question 1)
Develop a calculator to display the numbers of US dollar ($) bills, when a user inputs the total amount of money as an integer. For example, suppose that the input is 487. So the program displays

     $487 is
         $100 Bills       4
         $20  Bills       4
         $5   Bills       1
         $1   Bills       2

Of course, there are many other combinations. You have to develop a program to calculate the result so that the number of bills is minimum. In the above case, 11 (4 + 4 + 1 + 2) is the minimum. If you have more $20 bills, then the number is increased.

Question 2)
Develop a calculator to display the numbers of Day, Hour, Minute, and Second, when a user inputs the total amount of time in seconds. For example, suppose that the input is 239,782 seconds. The program displays:

 

239,782 seconds are
       2    Days
      18    Hours
      36    Minutes
      22    Seconds

Part 2: Programming

Write a program called Assignment1.java for Question 1 and 2 in Part 1 above.

  • ï‚·  Question 1
    Display a question and ask the user type an amount of money. Once an integer is typed, then display the number of each US$ bill.
  • ï‚·  Question 2
    Display a question and ask the user type an amount of time in seconds
    Once an integer is types, then display the number of days, hours, minutes and seconds.
    At the last line, display the “**** End of Program ****”

• Display Form (5 pts): Look at the sample output carefully. Alignment of each word and number should be similar to the sample. (Look at the printf() method in textbook)

The program is to display questions and read user inputs, then calculate and print out the requested value with a proper format. This program will follow a very simple process as shown below.

Make a Scanner

IMPORTANT!

ï‚· It is allowed to make only one Scanner variable. In your PC, it may work with multiple Scanner variables, but the server site (online submission) may not accept it. If you make more than one Scanner variables, you may lose some points.

Q1) Get input

Calculate

Display results

Q2) Get input

Calculate

Display results

 

  • ï‚·  Use only the statements that have been covered in class to date. This means you CAN use the items in Chapter 1 and 2 of textbook. DO NOT use any other techniques (if-else, loops, Time Format, etc.) not explained in class. If in doubt, ask your TA or instructor. If you use them, only half score will be given at most. Be careful for this rule.
  • ï‚·  Complete each task one by one. If your program file does not run (compile error), then you may lose all 15 points.
  • ï‚·  Make ONLY integer variables. If a real/floating variable (double or float type) is used, 3 pts are reduced for each.

    Sample Output:

• The following is an example input and output. The user input is shown in red (489, and 239782). Test your program by making your own inputs rather than this example. Look at the comments/hints in the explosions.

ï‚· (Tips) Make use of (%) modulus operators to calculate the remainder and (/) divisions

with integers. Understand what are the results of (x % 100), (x % 60), and (x % 20).

----------------
INPUT 1
----------------
487

239782

—————-
YOUR OUTPUT 1
—————-
*** Question 1 ***
Please input the total amount of money. 489

    $487 is
        $100 Bills    4
        $20  Bills    4
        $5   Bills    1
        $1   Bills    2
*** Question 2 ***

Please input the time in seconds. 239782 239,782 seconds are

             2    Days
            18    Hours
            36    Minutes
            22    Seconds
*** End of Program ***
  • 1-meuoc6.zip