1. Use the program on the next page to answer the following questions. Write you
ID: 3565416 • Letter: 1
Question
1. Use the program on the next page to answer the following questions. Write your answer below each question. a) Write the header of the findNearestDollar method: b) Write the body of the findNearestDollar method: c) What is the formal parameter list for the findNearestDollar method? d) What is the return type of the findNearestDollar method? e) Where is the findNearestDollar method called? f) Write the code that calls the findNearestDollar method: g) What actual arguments are used in the call to the findNearestDollar method?
public static void main(String[] args)
{
double price;
Scanner keyboard = new Scanner(System.in);
System.out.println(
Explanation / Answer
//1. Use the program on the next page to answer the following questions.
//Write your answer below each question.
a) Write the header of the findNearestDollar method:
public static int findNearestDollar(double amount)
b) Write the body of the findNearestDollar method:
int intPart = (int)amount;
if (amount - intPart > .50)
return intPart + 1;
else
return intPart;
c) What is the formal parameter list for the findNearestDollar method?
double amount
d) What is the return type of the findNearestDollar method?
int
e) Where is the findNearestDollar method called?
System.out.println(
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.