KEMBAR78
Program List | PDF | Constructor (Object Oriented Programming) | Programming
0% found this document useful (0 votes)
4 views7 pages

Program List

program list

Uploaded by

Senben Liao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views7 pages

Program List

program list

Uploaded by

Senben Liao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Introduction to Java

Program List

Program1TempConversion

Write a GUI program that prompts the user to enter a temperature in degrees Fahrenheit (as an integer)
and outputs the corresponding temperature in degrees Celsius (which may or may not be an integer –
you have to account for either.) Your input and output windows should look like the following (note the
icons and headings of the windows);

Program2ChangeMachine

Write a GUI program that prompts the user to enter an amount of change (in cents.) The output will give
the minimum number of coins (by denomination) necessary for the change amount. Your input and
output windows should look like the following (note the icons and headings of the windows):

Program3FiveGuys

Write a GUI program that prompts the user to enter a number of cheeseburgers, regular fries, and regular
drinks from Five Guys. Use finals to declare the values of each ($6.95, $3.19, and $1.79 respectively.)
Calculate the subtotal, tax, and total cost of the purchase. The output should look like the following,
including the header and icon:
Extension - see if you can find a way to make the output look like this instead (notice the formatting of
the total):

Program4QuadraticFormula

Write a GUI program that will find the real solutions of a quadratic equation of the form ax 2  bx  c  0 . If
the roots are imaginary, a window will state “No real roots.” Otherwise, the real roots will be displayed.
Your windows should look like the following:

or

Program5DistanceFormula

Write a GUI program that will calculate the distance between two coordinate pairs (x1, y1) and (x2, y2).
The coordinate pairs should be integers – include something that reminds the user of this. The distance
between the points may or may not be an integer. Your output should look like:

Program6Average

Write a program that prompts the user to enter a list (of any size) of nonnegative integers and outputs
the following:

1. The maximum value of the integers.


2. The minimum value of the integers.
3. The average of the integers.
The end of the input should be indicated by the user entering any negative number (sentinel). Note: the
sentinel value should not be included in the calculations. Your output should look like:

Program7RandomNumbers

Generate 100 random numbers between 1 and 10. Display the numbers (non-GUI) horizontally,
separated by commas, and ending with a period. Make sure the “Build Successful” stuff is on the next line.
Determine how many of the randomly generated numbers are odd, even, prime, and perfect squares.
Display your results in a window like the following:

Program8SlotMachine

Create a slot machine application. The slot machine has three wheels that each display an integer from 1
to 5 inclusive. A player starts with 100 points and loses 50 points on each spin if the player matches no
numbers. If the numbers match in the following ways, points are awarded:

a. If any two numbers match – 10 points.


b. All 1’s – 50 points
c. All 2’s – 100 points
d. All 3’s – 150 points
e. All 4’s – 200 points
f. All 5’s – 250 points

The game ends when the player can no longer spin. Your output after each spin should look like:
As an extension, add a confirmDialog to prompt the user to end the game on their own.

Program9RandomNumberGuess

Write a GUI program that prompts the user to guess a random number from 1 to 100 inclusive. Make
sure you check to see if the guess is valid. Indicate whether the guess is too high, too low, or correct. If
too high or too low, continue guessing. Display the users guess each time. When correct, indicate that
and display the number of guesses.

If your program works correctly, the user should be able to guess the number in a maximum of 7 guesses.

Program10EmployeeClass

Design an Employee class with the attributes and methods below. Name the driver program
Program10EmployeeClass, and name the class Employee.

Attributes: String name Methods: void setEmployee()


String empNumber void getEmpolyee()
double hourlyRate double calcGrossPay()
double hoursWorked double calcTaxes() //use 19.72%
double calcNetPay()

calcGrossPay() should return a double and calculate the gross pay for an Employee. Any hours
worked over 40 should earn time and a half (1.5 times the hourly rate.)

Program11Palindrome

A palindrome is a word, phrase, or sentence that is the same letters forward and backward. Some
examples are “Mom”, “Radar”, or Mr. Szarko’s favorite “Go hang a salami, I’m a lasagna hog!” Design a
class called Palindrome (with the driver called Program11Palindrome) with the following attributes
and methods below. When testing to see if a word or phrase is a palindrome, we want to ignore case,
spaces and any punctuation.

Attributes: String word Methods: void setWord()


String newString void buildString()
String backwards void buildBackwards()
Boolean checkPanlindrome()
Program12DiceGame

Create a dice game where one die is rolled. Prompt the user to guess whether the next roll will be over or
under the first roll. Roll the die again and display whether the user won or lost. Keep track of the
number of wins and losses and when either reaches 5, the game is over. Use the Die class to create your
die. Name the client program Program12DiceGame.

Program13QBRating

This class will use the NFL’s QB rating formula to calculate a QB rating. Use the QB Rating Formula
document from my website to help. Your class (named QB) must include the attributes and methods
below. For the default constructor, use Steve Young’s data from 1994 – it’s in the QB Rating Formula
document.

private String name; Default and overloaded constructors


private int attempts; double completionPercent()
private int completions; double intPercent()
private int td; double tdPercent()
private int interceptions; double ydsPerAtt()
private int yards; double qbRating()

Program14RaulIbanez

Write a class that has methods to calculate the average number of home runs, the minimum number of
home runs, and the maximum number of home runs for Raul Ibanez’s 19 year career. As a bonus, write a
method to find the mode number of home runs. Attributes and methods are listed below. Name your
files using the following:

Driver program: Program14RaulIbanez


Class: Raul

Attributes: Methods:

private static int[] hr = { …data…} public static double avgHR()


public static int maxHR()
public static int minHR()
public static int[] modeHR() //this one is a bonus

Your output within the driver program should look like:


Program15LetterCount

Write a program that will accept input from the user in the form of a string and outputs the number of
occurrences of each letter. The user can either input the sentence using the setSentence method, or can
overload the constructor.

Driver program: Program15LetterCount


Class file: LetterCount

Attributes: Methods:

String sentence Constructors


int[] letterCount = new int[26] Default – “The quick brown fox jumps over the lazy dog.”
void setSentence()
void countLetters()
void displayLetters()

The output should look like the following:

Program16AirplaneSeating

Write a (partially) GUI program to simulate buying seats on an airplane. Assume the airplane has 20
rows (labeled 1 – 20) and six seats per row (labeled ‘A’ to ‘F’.)

Driver program: Program16AirplaneSeating


//Loop in here keeps prompting user to enter seats
Class file: AirplaneSeat
Attributes: char[][] seatingChart = new char [20][6]

Methods: public AirplaneSeat()


//default – fills seats with ‘O’

public void displaySeats()


//displays the seating chart initially as empty
//redisplays with filled seats

public void pickSeat()


//Allows the user to enter a seat by row
//and column – two separate input dialog boxes
//Must verify that seat is valid
//Must verity that seat has not already been filled

public boolean pickAgain()


//Returns true if the user wants to pick another seat

Samples (non-GUI and GUI)

You might also like