CSE 110 Fall 2015
©Kanika Grover Page 1
LastName ____________________FirstName__________________Class Time____________
public class Question1
{
public static void main(String[] args)
{
String name = "Elizabeth";
if(name.length()>8)
System.out.println("Allowed");
else
System.out.println("Not allowed");
}
}
Question 2. Write the output of the following program in the box: (3 pts)
public class Question2
{
public static void main(String[] args)
{
System.out.println(Math.pow(8,3));
double num = Math.sqrt(512);
System.out.println(Math.round(num));
if(num<0)
System.out.println("negative");
else if (num>0 && num<22)
System.out.println("small");
else
System.out.println("general case");
}
}
Allowed
512.0
23
general case
Class Activity 5 Maximum Points:10
Question 1. Write the output of the following program in the box: (2 pts)
CSE 110 Fall 2015
©Kanika Grover Page 2
Question 3. Write the output of the following program in the box: (3 pts)
public class Question3
{
public static void main(String[] args)
{
int score = 90;
if(score>=90)
System.out.println("Grade A");
if(score>80)
System.out.println("Grade B");
if(score>70)
System.out.println("Grade C");
if(score>60)
System.out.println("Grade D");
}
}
Question 4. State True or False in the blank following each line: (2 pts)
public class Question4
{
public static void main(String[] args)
{
int x = 600;
int y = 1000;
System.out.println(( x > 500 && x < 650) || (y != 100));
//_true_
System.out.println((x > 500 || x < 650) && !(y == 1000));
//_false_
System.out.println(( x > 500 && x < 650) || ( y != 1000));
//_true_
System.out.println((x >= 500 || x <=650) && ( y != 1000));
//_false_
}
}
Grade A
Grade B
Grade C
Grade D
Powered by TCPDF (www.tcpdf.org)