

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: OBJECT-ORIENTED PROG I; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


CMSC 131 Spring 2005 Quiz 1 Worksheet
The first Quiz of the course will be on Wednesday Feb 2 during your lab (discussion) session.. The following bullet list provides more information about the quiz:
The following exercises cover the material you are expected to be familiar for Quiz #1, Solutions to these exercises will not be provided but you are welcome to discuss your solutions with TAs and instructors during office hours.
1. From Lewis & Loftus a. Page 56 (“programming projects section”): 1.1, 1. b. Page 120 (“exercises”): 2.2, 2.6 (a, b, c, d, e, f, g, n, o, p, q) c. Page 123 (“programming projects”): 2.2, 2.3, 2.5, 2. 2. Write a Java program that computes the letter grade associated with student based on a numeric grade value. The program will read the numeric grade of the student and will compute a letter grade using the following cutoff values:
Letter Grade Cutoff
Any student with a numeric grade value lower than 60.0 will have F as letter grade.
3. Note: This problem was last semester’s quiz. The solution has been provided at the end.
Write a Java program that prompts the user for two values, computes the average of the values and generates a message based on the computed average. The message “Satisfactory” will be output if the average is greater or equal to 70.0 and “Unsatisfactory” otherwise. The following restrictions/assumptions apply to this problem:
Problem 3 Solution
import javax.swing.*; public class ComputeStatus {
public static void main(String[] args) { String strVal1 = JOptionPane.showInputDialog("Enter Value"); String strVal2 = JOptionPane.showInputDialog("Enter Value"); double val1 = Double.parseDouble(strVal1); double val2 = Double.parseDouble(strVal2); double avg = (val1 + val2)/2;
String message = "Satisfactory"; if (avg < 70.0) { message = "Unsatisfactory"; }
JOptionPane.showMessageDialog(null, message); System.exit(0); } }