Practice Quiz #2 - Object-Oriented Programming I | CMSC 131, Quizzes of Computer Science

Material Type: Quiz; Class: OBJECT-ORIENTED PROG I; Subject: Computer Science; University: University of Maryland; Term: Spring 2005;

Typology: Quizzes

2019/2020

Uploaded on 11/25/2020

koofers-user-i1a-1
koofers-user-i1a-1 🇺🇸

5

(1)

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMSC131 Spring 2005, Quiz #2, Duration 15 Minutes
First Name: Last Name:
Student Id: Section: TAs:
Write a Java program that reads two values representing the lower bound and upper bound of a
positive integer range, and then prints the even values of that range. For example, for the range
[7, 12] your program will generate the values 8 10 12. Each value should be printed on a line
by itself. If the lower bound is greater than or equal to the upper bound your program should
print the message “Invalid Range”. The following restrictions/assumptions apply to this problem:
The name of the class you will define is EvensInRange.
Use the messages “Enter lower bound” and “Enter upper bound” to read the upper and
lower bounds, respectively.
Input operations must be completed using methods associated with JOptionPane.
Output operations must be completed using System.out.println.
You do not need to provide comments, however, you must use meaningful variable
names and good indentation.
You must write any necessary import statements.
Write the program on the next page.
Hint: Remember that the % operator generates the remainder in an integer division.
WRITE YOUR ANSWER ON THE NEXT PAGE.
pf3

Partial preview of the text

Download Practice Quiz #2 - Object-Oriented Programming I | CMSC 131 and more Quizzes Computer Science in PDF only on Docsity!

CMSC131 Spring 2005, Quiz #2, Duration 15 Minutes

First Name: Last Name: Student Id: Section: TAs:

Write a Java program that reads two values representing the lower bound and upper bound of a positive integer range, and then prints the even values of that range. For example, for the range [7, 12] your program will generate the values 8 10 12. Each value should be printed on a line by itself. If the lower bound is greater than or equal to the upper bound your program should print the message “Invalid Range”. The following restrictions/assumptions apply to this problem:

  • The name of the class you will define is EvensInRange.
  • Use the messages “Enter lower bound” and “Enter upper bound” to read the upper and lower bounds, respectively.
  • Input operations must be completed using methods associated with JOptionPane.
  • Output operations must be completed using System.out.println.
  • You do not need to provide comments, however, you must use meaningful variable names and good indentation.
  • You must write any necessary import statements.
  • Write the program on the next page.
  • Hint: Remember that the % operator generates the remainder in an integer division.

WRITE YOUR ANSWER ON THE NEXT PAGE.