Java Programming

Amanda Thomas February 6, 2009 at 20:06:34
Specs: Windows Vista

Need to write a java statement that imports the class scanner.
Write a Java statement that declares scan be a Scanner object for inputting data from the standard device.
Write Java statements that declare and initialize the following named constants: CODE of the type int initialized to 15 and HOURLY of type double initialized to 12.50.
Write Java statements that declare the following variables: num1, num2, and newNum of the type int; firstName of the type string; and hoursWorked and pay of the type double.
Write Java statements that prompt the user to input two intergers and store the first number in num1 and store the seconed number in num2. Assume valid input is entered.

See More: Java Programming

Report •


#1
February 9, 2009 at 19:30:03

Need to write a java statement that imports the class scanner.

import java.util.Scanner;

Write a Java statement that declares scan be a Scanner object for inputting data from the standard device.

// Scanner keyboard input setup;
Scanner scan = new Scanner(System.in);

Write Java statements that declare and initialize the following named constants: CODE of the type int initialized to 15 and HOURLY of type double initialized to 12.50.

final int CODE = 15;
final double HOURLY = 12.50;

Write Java statements that declare the following variables: num1, num2, and newNum of the type int; firstName of the type string; and hoursWorked and pay of the type double.

int num1, num2, newNum;
String firstName;
double hoursWorked, pay;

Write Java statements that prompt the user to input two intergers and store the first number in num1 and store the seconed number in num2. Assume valid input is entered.

System.out.print ("Enter first integer: ");
num1 = scan.nextInt();
System.out.print ("Enter second integer: ");
num2 = scan.nextInt();

(P.S. - Spend a week (every night) and read chapters 2 & 3 and practice the examples. To succeed, you will need to know these basics to build yourself a solid foundation... otherwise the rest of the course will be next to impossible to understand.)

Good luck!


Report •
Related Solutions


Ask Question