WIX1002 Fundamentals of Programming Lab 8: Class

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (8 votes)

1. Define a class name Number. The class is used to handle an integer array. The class
Number will display all the item of the array, the even number, the prime number, the
maximum number, the minimum number, the average, the square number. Create a
Tester class to test the program.
Number a = new Number() // generate 10 random integers within 0 to 100.
Number b = new Number(5) // generate 5 random integers within 0 to 100.
Number c = new Number(4, 50) // generate 4 random integers within 0 to 50.
2. Define a class name BankAccount. The class allows the customer to open the saving
account with their name, IC or passport number and the deposit amount. The class
consists of deposit method and withdraws method. Besides, the class can display the
current balance. Create a Tester class to test the program.
3. Define a class name WeightCalculator. The class has an input method that accepts the
user’s age and height. Besides, the class consists a method that calculating the
recommend weight with this formula
recommend weight = (height – 100 + age / 10) * 0.9
The class will display the user’s age, height and the recommend weight. Create a
Tester class to test the program.
4. Define a class Fraction. The class has an input method that accepts the numerator and
the denominator from the user. Use the mutator method to set the numerator and
denominator and the accessor method to get the value of numerator and denominator.
This class also has a method to display the fraction reduced to lowest terms. (find the
greatest common divisor for the numerator and denominator. Create a Tester class to
test the program.
5. Define a class Game. The class has a constructor that accept player name. Besides,
the class contains a method move that roll the dice. Create a Tester class to test the
program with two players and the player that reach 100 or more win the game.
6. You operate several burger stalls distributed throughout town. Each burger stall has
an ID and the number of burger sold for the day. The class consists of a constructor to
initialize the instance variables and a sold method that increment the number of
burger sold by parameter value. The class also contains a variable and method that
tracks the total number of burgers sold in all stalls. Display the total burger sold by
each stall and the total number of burgers sold in all stalls.
7. Define class money. The class is used to calculate the number of note and coins for a
given amount of money. The available notes are RM100, RM50, RM10, RM5 and
RM1. The available coins are 50cent, 20cent, 10cent and 5 cent. The class needs to
2
round up the amount according to the table below. The class also contains addition
and subtraction method to add or subtract two objects.
Before Rounding After Rounding
10.11, 10.12 10.10
10.13, 10.14, 10.16, 10.17 10.15
10.18, 10.19 10.20