Robotics C++ Physics II AP Physics B Electronics Java Astronomy Other Courses Summer Session  

Methods

 

 

Exercise 1       You may find this code useful

 

In the main method, prompt the user to enter an integer grade between 0 and 100.

Pass this grade to a method named conversion

 

The conversion method will use the following logic to convert the integer grade to a letter

grade, A, B, C, D, or F according to the following logic.

 

   If the grade is greater than or equal to 90 and less than or equal to 100 then letter grade = A

   If the grade is greater than or equal to 80 and less than 90 then letter grade = B

   If the grade is greater than or equal to 70 and less than 80 then letter grade = C

   If the grade is greater than or equal to 60 and less than 70 then letter grade = D

   If the grade is less than 60 then letter grade = F

 

When the letter grade is returned to the main method, the main method will pass it to a method named

printIt.  The method named printIt will print the numeric grade and its equivalent letter grade

 

 

 

Exercise 2

Assume that you are the mananger of a restaurant.

 

Establish a price for cokes, fries, and burgers and set a tax rate and make them global variables. No other variables can be global

Note: a global variable is a variable defined outside any method - place them above the main

 

In the main program  

 

   Call a method to greet the customer (assume only 1 customer - do not use a loop)

   Call a method to state prices

   Call a method to take number of cokes

   Call a method to take number of fries

   Call a method to take number of burgers

   Call a method to calculate the total price

   Call a method to announce the price

   Call any necessary methods not mentioned above 

Write the following methods

   Those necessary to accomplish the above

 

Exercise 3

Ask the customer how much money he is providing in payment in terms of dollars, quarters, dimes, nickles, and pennies.

Calculate and tell the customer what the change is in terms of the above, as appropriate.