Java Reference
In-Depth Information
{String firstName,lastName; int num;
double salary;
System.out.print ("Enter first name: "); firstName=
console.next(); System.out.println();
System.out.print("Enter last name: ");
lastName=console.next(); System.out.println();
System.out.print("Enter a positive integer less than 70:";
num = console.nextInt(); System.out.println(); salary=num*X;
System.out.println("Name: " + firstName + BLANK + lastName);
System.out.println ("Wages: $"+salary); System.out.println ("X = " + X);
System.out.println("X+Y = " + (X+Y));
}}
35. What type of input does the following program require, and in what order
must the input be provided?
import java.util.*;
public class Strange
{
static Scanner console = new Scanner(System.in);
public static void main(String[] arg)
{
int x;
int y;
String name;
x = console.nextInt();
name = console.nextLine();
y = console.nextInt();
}
}
PROGRAMMING EXERCISES
1. Write a program that produces the following output:
**********************************
* Programming Assignment 1 *
* Computer Programming I *
* Author: Duffy Ducky *
* Due Date: Thursday, Jan. 24 *
**********************************
2. Consider the following program segment:
//import classes
public class Exercise2
{
public static void main(String[] args)
 
Search WWH ::




Custom Search