Ch 1
import javax.swing.JOptionPane;
public class salesJune
{
public static void main(String[] args)
{
int storeSales = 250;
}
}
. JOptionPane.showMessageDialog(null, "Congratulations! June sales were $" + storeSales + "!";
if(payRate < 5.85 || payRate > 60)
System.out.println("Error in pay rate");
while (x < a + b)
// loop body
int sum = a + b;
while(x < sum)
// loop body
final int COST_PER_ITEM= 10;
double sales2012 = amtSold * COST_PER_ITEM;
In the above statements, identify the named constant and describe how a programmer can recognize named constants.
if (maxValue = 100)
System.out.println ("Your limit has been reached");
Why is the above if statement illegal? How would you fix it?
if(maxValue == 100)
System.out.println("Your limit has been reached");
counterLoop = 1;
while(counterLoop < 10);
{
System.out.println("Hello");
counterLoop = counterLoop + 1;
}
What is the problem in the above while loop? How would you correct the problem?
public class FindMyErrors
{
public static void main(String[] args)
{
System.out.println(“My application with errors)
}
Given the above code, identify three separate syntax errors.
System.out.println(“First Java application”);
Given the above code, identify and describe the use of a literal string and the use of parentheses.
public class IncrDemo
{
public static void main(String[] args)
{
int myVal, yourVal;
myVal = 10;
System.out.println("My initial value is " + myVal);
yourVal = ++myVal;
System.out.println("My new value is " + myVal);
System.out.println("Your value is " + yourVal):
}
}
Using the above code, describe how the three println output commands will appear. Explain the values stored in the variables during code execution.
if(payRate < 5.85 && payRate > 60)
System.out.println("Error in pay rate");
if(payRate < 5.85 || payRate > 60)
System.out.println("Error in pay rate");
while(10 > 1)
{
System.out.println("Hello!");
}
Identify the problem that exists in the above while loop.
if(firstValue == secondValue)
{
int total = firstValue + secondVaue;
System.out.println("The values are equal");
}
System.out.println("The total is " + total);
Why will the above println() statement cause an error?
num
:
import java.util.Random;
public class Lotto{
public static void main(String[] args){
Random myRandom = new Random();
int num;
______________________
System.out.println("And the winner is: " + num);
}
}
num = myRandom.nextInt(40) + 1;