Univeristy of Nizwa
College of Economics, Management and Information Systems / / Sunday 01/042012
05:00 PM
Lab 8-5
60 minutes
Worth 10%
Dr. Tarek Guesmi
Semester : Spring 2012
Lab Exam
COMPUTER SYSTEMS CONCEPTS (INFS-522)

NAME...... …...... ID...... SIGN......

Exercise 2

Rational numbers are numbers that can be represented as a fraction p / q where p is an integer number and q is a positive integer (q != 0).

Design and implement a Java class RationalNumber for representing such numbers. Implement methods to add und mutliply rational numbers. Implement a method for return the value of a rational number as a double value.

Put your code here

Exercise 3

Consider the following class:

public class IdentifyMyParts {

public static int x = 7;

public int y = 3;

}

  1. What are the class variables?

……………………………………………………………………………………………

  1. What are the instance variables?

……………………………………………………………………………………………..

  1. What is the output from the following code:

IdentifyMyParts a = new IdentifyMyParts();

IdentifyMyParts b = new IdentifyMyParts();

a.y = 5;

b.y = 6;

a.x = 1;

b.x = 2;

System.out.println("a.y = " + a.y);

System.out.println("b.y = " + b.y);

System.out.println("a.x = " + a.x);

System.out.println("b.x = " + b.x);

System.out.println("IdentifyMyParts.x = " +

IdentifyMyParts.x);

…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

Exercise 4

Write a Java program according to the problem specifications and constraints specified below.

Problem Definition

Determine the letter grade earned by a student from exam, and lab or project points.

Input (DialogBox)

A student name, three exam scores, and a lab or project score total.

Output (Command line)

Show total points and the resulting letter grade along with identifying labels.

Processing

Sum the points earned on the exams, and labs or projects. Determine a letter grade from the point total. For a point total >= 90% of points possible, assign the letter grade "A"; a point total >= 80% (and < 90%), assign "B"; ...and for a total less than 60% of points possible, or total lab/project points < 120, assign "F".

Put your code here