You are on page 1of 5

import (keyword) java.util. (object ???

) * (arithmetic operator) ;
(separator)
public (keyword) class (keyword) DOUBLE (identifier)
{ (separator)
static (keyword) Scanner (???) console (???) = (assignment
operator) new (keyword) Scanner (???) ( (separator) System.in
(object) ); (separator)
public (keyword) static (keyword) void (keyword) main (user
identifier) ( (separator) String (class name identifier) [] (separator)
args (user identifier) ){ (separator)
String (primitive) ans (identifier) ; (separator)
int (primitive) choice (identifier) ; (separator)
int (primitive) [] (separator) quizzes (identifier) ; (separator)
int (primitive) [] (separator) sqrt (identifier) ; (separator)
int (primitive) quiz (identifier) , (separator) num (identifier) ;
(separator)
do (keyword) { (separator)
int (primitive) counter (identifier) = (assignment operator) 0
(int literal) ; (separator)
System.out. (object) println (method) (); (separator)
System.out. (object) println (method) ("-----------------") (String
literal) ; (separator)
System.out. (object) println (method) ("----MAIN MENU----")
(String literal) ; (separator)
System.out. (object) println (method) ("-----------------") (String
literal) ; (separator)
System.out. (object) println (method) (" 1.Average of quizzes")
(String literal) ; (separator)
System.out. (object) println (method) (" 2.Square of Numbers")
(String literal) ; (separator)
System.out. (object) println (method) (" 3.Exit") (String literal) ;
(separator)
System.out. (object) println (method) ("*****************")
(String literal) ; (separator)
System.out. (object) print (method) ("Enter your choice: ")
(String literal) ; (separator)

choice (variable identifier) = (assignment operator)


console.nextInt (method) (); (separator)
System.out. (object) println (method) ("*****************")
(String literal) ; (separator)
System.out. (object) println (method) (); (separator)
if (keyword) ( (separator) choice (variable identifier) ==
(relational operator) 1 (int literal) ){ (separator)
System.out. (object) print (method) ("How many quizzes: ")
(String literal) ; (separator)
quiz (variable identifier) = (assignment operator)
console.nextInt (method) (); (separator)
quizzes (variable identifier) = (assignment operator) new
(keyword) int (primitive) [ (separator) quiz (variable identifier) ];
(separator)
System.out. (object) println (method) (); (separator)
for (keyword) ( (separator) int (primitive) I (identifier) =
(assignment operator) 0 (int literal) ; (separator) i (identifier) <
(relational operator) quiz (identifier) ; (separator) i (identifier) ++
(increment operator) ){ (separator)
counter (identifier) ++ (increment operator) ; (separator)
System.out. (object) print (method) ( (separator) "Enter
quiz #" (String literal) + (arithmetic operator) counter (variable
identifier) + (arithmetic operator) ": " (String literal) ); (separator)
quizzes (variable identifier) [ (separator) i (variable
identifier) ] (separator) = (assignment operator) console.nextInt
(method) (); (separator)
} (separator)
System.out. (object) println (method) ( (separator) "The
average of the " (String literal) + (arithmetic operator) counter
(variable identifier) + (arithmetic operator) " Quizzes is: " (String
literal) + (arithmetic operator) average (method) ( (separator)
quizzes (variable identifier) , (separator) quiz (variable identifier) )
(separator) + (arithmetic operator) "\n" (escape sequences) );
(separator)

}
if (keyword) ( (separator) choice (variable identifier) ==
(relational operator) 2 (int literal) ){ (separator)
System.out. (object) print (method) ("How many numbers: ")
(String literal) ; (separator)
Num (variable identifier) = (assignment operator)
console.nextInt (method) (); (separator)
sqrt (variable identifier) = (assignment operator) new
(keyword) int (primitive) [(separator) num (variable identifier) ];
(separator)
System.out. (object) println (method) ();(separator)
for (keyword) ( (separator) int (primitive) i (variable
identifier) = (assignment operator) 0 (int literal) ; (separator) i
(variable identifier) < (relational operator) num (variable
identifier) ; (separator) i (variable identifier) ++ (increment
operator) ){ (separator)
counter (variable identifier) ++ (increment operator) ;
(separator)
System.out. (object) print (method) ("Enter number #"
(String literal) + (arithmetic operator) counter (variable identifier)
+ (arithmetic operator) ": "); (separator)
sqrt (variable identifier) [ (separator) i (variable
identifier) ] (separator) = (assignment operator) console.nextInt
(method) (); (separator)
} (separator)
System.out. (object) println (method) ("The squares of the
number(s):" (String literal) + (arithmetic operator) sqrt (method)
(sqrt (variable identifier) , (separator) num (variable identifier) )
(separator) + (arithmetic operator) "\n" (escape sequences) );
(separator)
} (separator)
System.out. (object) println (method) ("Goodbye!" (String
literal) ); (separator)
System.out. (object) print (method) ("Do you want to try again?

Yes or No "); (separator)


ans = console.next(); (separator)
} (separator) while (keyword) (ans.equalsIgnoreCase("YES")
(String literal) ); (separator)
}(separator)
public (keyword) static (keyword) double (identifier) average
(method) (int (primitive) [] (separator) Q (identifier) , (separator)
int (primitive) quiz (identifier) ){ (separator)
double (primitive) ave (identifier) ; (separator)
int (primitive) sum (identifier) = 0; (separator)
for (keyword) ( (separator) int (primitive) i (identifier) =
(assignment operator) 0 (int literal) ; (separator) i (identifier) <
(relational operator) quiz (identifier) ; (separator) i (identifier) ++
(increment operator) ){ (separator)
sum (variable identifier) = (assignment operator) sum
(variable identifier) + (arithmetic operator) Q (variable identifier) [
(separator) i (variable identifier) ]; (separator)
} (separator)
ave (variable identifier) = (assignment operator) sum (variable
identifier) / (arithmetic operator) quiz (variable identifier) ;
(separator)
return (keyword) ave (variable identifier) ; (separator)
} (separator)
public (keyword) static (keyword) String (identifier) sqrt (method)
( (separator) int (primitive) [] (separator) sqrt (identifier) ,
(separator) int (primitive) num (identifier) ){ (separator)
int (primitive) [] (separator) srt ; (separator)
int (primitive) square; (separator)
String (primitive) n =""; (separator)
srt (variable identifier) = new int [ ( ) num (variable identifier) ];
(variable identifier)

for (keyword) ( (separator) int (primitive) i (variable identifier)


= (assignment operator) 0 (int literal) ; i (variable identifier) <
(relational operator) num (variable identifier) ; i (variable
identifier) ++ (increment operator) ){ (separator)
square (variable identifier) = sqrt[i] * sqrt[i]; (separator)
srt (variable identifier) [ (separator) i (variable identifier) ]
(separator) = square; (separator)
n (variable identifier) = (assignment operator) n (variable
identifier) + (arithmetic operator) " " (String literal) + (arithmetic
operator) srt (variable identifier) [ (separator) i (variable
identifier) ]; (separator)
} (separator)
return (keyword) n (variable identifier) ; (separator)
} (separator)
} (separator)

You might also like