1 / 2100%
CSE 110 Fall 2015
©Kanika Grover Page 1
LastName ____________________FirstName__________________Class Time____________
Class Activity 3 Maximum Points:10
public class ArithmeticOper
{
public static void main(String[] args)
{
int num1 = 258;
double num2 = 8.0;
System.out.println(Math.pow(num2,3));
// What is the output of the above?___512.0_
System.out.println(num1/num2);
// What is the output of the above?____32.25_____
System.out.printf("%.2f\n",num1%num2);
// What is the output of the above?____2.00_____
System.out.println(Math.round(3.2*num1/3*num2));
// What is the output of the above?____2202__
}
}
public class StringOperations
{
public static void main(String[] args)
{
String string1 = "ANNA";
String string2 = "Jones";
System.out.println(string1.length());
// What is the output of the above?____4___
System.out.println(string2.substring(1,3));
// What is the output of the above?____on____
System.out.println(string1+" "+string2.toUpperCase());
// What is the output of the above?____ANNA JONES_
System.out.println(string2.replace('o','a'));
// What is the output of the above?________Janes__
System.out.println(string2.indexOf("n")*3);
// What is the output of the above?______6____
System.out.println(string1.equals("Anna"));
// What is the output of the above?__false____
}
CSE 110 Fall 2015
©Kanika Grover Page 2
}
Powered by TCPDF (www.tcpdf.org)
Students also viewed