Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please show me how to complete the code. I'm not even sure what the objective is... public class MethodsPractice { public static void main(String[] args)

Please show me how to complete the code. I'm not even sure what the objective is...

public class MethodsPractice {

public static void main(String[] args)

{

// Intro

System.out.println("Testing Methods ...");

// Prompt user for a Linux System Error Code & display the

// corresponding error message

int errorCode;

errorCode = getInt("Linux System Error Code");

displayError(errorCode);

// Prompt user for a temperature in Celsius

// and display the corresponding Fahrenheit

// Fahrenheit = 9.0 / 5.0 * celsius + 32

double celsius, fahrenheit;

celsius = getDouble("Temperature in Celsius");

fahrenheit = celsiusToFahrenheit(celsius);

System.out.printf(" %f Degree Celsius is equivalent to %f Fahrenheit. ",

celsius, fahrenheit);

// Prompt user for an integer value n (>0),

// Calculate & display its factorial

// 0! = 1

//n! = 1 * 2 * 3 * ... * n

int n, fact;

n = getInt("a number (>0)");

fact = Factorial(n);

System.out.println(" The factorial of %d is %d. ", n, fact );

// Given a month, day, and year, display the corresponding date

int month, day, year;

month = getInt("month (1-12)");

day = getInt("day (1-31");

year =getInt("year");

displayDate(month, day, year);

}

/**

* Prompt user for an integer number (described by prompt) and return

* its value to the caller.

*

* @param prompt - Number label

*

* @return Number entered by the user

*/

int getInt(String prompt)

{

int number;

return number;

}

/**

* Given a Linux system error code, displays an error message, such that:

* 1 - Operation not permitted

* 2- No such file or directory

* 5- I/O error

* 12 - Out of memory

* 13 - Permission denied

* 16 - Device or resource busy

*

* @param code

*/

void displayError(int code)

{

}

/**

* Given a temperature in Celsius, returns the corresponding

* temperature in Fahrenheit

*

* @paramc - temperature in Celsius

* @return Temperature in Fahrenheit

*/

double celsiusToFahrenheit(double c)

{

double f;

// Calculate fahrenheit

return f;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions

Question

[![Review Assignment Due...

Answered: 1 week ago