Java Reference
In-Depth Information
public class Ch2_PrExercise5
{
static Scanner console = new Scanner(System.in);
2
import java.util.*;
{
public static void main(String[] args)
int width;
System.out.print("Enter the length: ");
width = console.nextInt();
System.out.println();
int length;
System.out.print("Enter the width: ");
length = console.nextInt();
System.out.println();
area = length * width;
System.out.println("Area = " + area);
System.out.println("Perimeter = " + perimeter);
perimeter = 2 * (length + width);
int area;
int perimeter;
}
}
6. Write a program that prompts the user to input a decimal number and
outputs the number rounded to the nearest integer.
7. Write a program that prompts the user to enter five test scores and then
prints the average test score.
8. Write a program that prompts the user to input five decimal numbers. The
program should then add the five decimal numbers, convert the sum to the
nearest integer, and print the result.
9. Write a program that does the following:
a. Prompts the user to input five decimal numbers
b. Prints the five decimal numbers
c. Converts each decimal number to the nearest integer
d. Adds the five integers
e. Prints the sum and average of the five integers
10. Write a program that prompts the capacity, in gallons, of an automobile fuel
tank and the miles per gallons the automobile can be driven. The program
outputs the number of miles the automobile can be driven without refueling.
Search WWH ::




Custom Search