1 int num 70 max 25 if num max 2 Systemoutprintln Apple Systemoutprintln Orange

1 int num 70 max 25 if num max 2 systemoutprintln

This preview shows page 6 - 10 out of 10 pages.

1.int num = 70, max = 25; if (num <= max * 2) System.out.println ("Apple"); System.out.println ("Orange"); 2.int total = 50; int max = 30; total = (total > max) ? total + 1: total * 2;
Background image
7 );
Background image
8
Background image
9 IV.(21 Points). Write code 1.(7 points). How would you write the following arithmetic expression in java? double x = −?+ √?2−4??2?2.We need command-line arguments to use a program. The arguments are “John Smith” “CS 1301A” 3.45 Complete the method below to assign the command-line values to the variables below. public static void main (String [] a){ String name, course; double gpa; int age; //Assign }//end of main 19
Background image
10 3.Complete the method below that accepts an integer score and prints the corresponding letter grade. Assume we assign ‘A’ to score >= 90, ‘B’ to score >= 80 and < 90, …, and ‘F’ to score < 60. Display “?” if score is negative.No need to read score from keyboard. The score will be passed from the driver to score in method. public void computeGrade (int score){ char grade; }//end of computeGrade
Background image

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture