//****************************************************
// Silly program
//****************************************************
public class Silly
{
//-----------------------------------------
// The main method prints some things.
//-----------------------------------------
public static void main (String[] args)
{
int sideLength = 5;
int area = sideLength * sideLength;
int perimeter = 4 * sideLength;
System.out.println ("A square with side of length " + sideLength
+ " has area " + area);
System.out.println ("The perimeter is " + perimeter);
sideLength = sideLength + 7;
area = sideLength * sideLength;
System.out.println ("A square with side of length " + sideLength
+ " has area " + area);
System.out.println ("The perimeter is " + perimeter);
}
}
OUTPUT:
size = 43;
size = size + 7;
size = size * 2;
size = size / 4;
int a = 3, b = 10, c = 7; double w = 12.9, y = 3.2;
- a + b * c
- a - b - c
- a / b
- b / a
- a - b / c
- w / y
- a + w / b
- a % b / y
- b % a
- w % y
- (double) a / b
- b / 100
- b / 100.
- The following program reads three integers and prints the average. Fill in the blanks so that it will work correctly.
// ******************************************************************** // FILE: Average.java // Purpose: Read three integers from the user and print their average // ******************************************************************** import __________________________________________; public class Average { public static void main(String[] args) { int val1, val2, val3; double average; // Create a Scanner object named scan __________________________________________________ ; // get three values from user System.out.println("Please enter three integers and " + "I will compute their average"); __________________________________________________ ; __________________________________________________ ; __________________________________________________ ; //compute the average and store in the variable average __________________________________________________ ; //print the average with appropriate label (not just the number!) ______________________________________________________ ; } }