Professional Documents
Culture Documents
CPSC6548 FA21 Lab Assignment#3
CPSC6548 FA21 Lab Assignment#3
Part I (20 Points): The objective of this lab is to find out the “true” MPG (Miles Per Gallon) of a vehicle, given a group of
conditions which the user provides values for. 5 are given, 1 you create on your own. Requirements:
Prompt the user for the car’s MPG first. i.e. Please Enter MPG: 26
Then prompt the user to enter a value for six factors which will affect the MPG of the vehicle, prompting for single
value inputs after showing menus (i.e. a series of println() statements showing the options/valid values to enter)
After collecting all of the inputs, provide a detailed report of the inputs, their meaning, how much they affect
MPG, as well as the beginning and final MPG.
6. Add one additional factor which you will prompt the user for, that affects MPG such as
tire pressure/condition,
hybrid vs. gas powered,
engine condition,
towing load,
2WD/4WD,
etc.
Turning in your work, .zip file contents: Do not submit the .class file or other project files. Please submit only working
java programs (i.e. debugged without syntax errors, and compile-able) as well as the Word document containing the
output (screenshots or text copy/paste) produced by your programs.
Part II (20 Points): The purpose of this program is to use data types/variables, various selection structures, random
number generation, input/output, performing calculations and formatting output.
Description: You have just been given the opportunity to win prizes from a sweepstakes entry you made at the county
fair! The opportunity includes winning 4 prizes, each will be determined by a different game of chance. You may create
your own descriptions for the prizes and values as you like, just make sure they are patterned as follows. Each of these
requires a random number generation.
1. Flip a coin: Depending upon the heads or tails result, you will get prize1:
a. Heads: A smartphone charger worth $9.99
b. Tails: A 9-volt battery and a wire worth $0.49 (the booby prize)
2. Roll a six-sided die: Depending upon the number that comes up, you will get prize2:
a. 1: A refrigerator magnet worth $1.49
b. 2: A handy grocery bag worth $.59 (the booby prize)
c. 3: A half-price ticket to next year’s fair worth $4.00
d. 4: A CD with hits from 12 bands playing at the fair worth $12.00
e. 5: A coupon for a free item at one of the concession stands worth $5.00
f. 6: A stuffed animal penguin worth $8.00
3. Spin a roulette wheel: Depending on the color (red or black) and the number (1 to 100), you will get prize3:
a. Red doubles the prize, Black triples the prize
b. Spin 1-20: Earn a penny (the booby prize)
c. Spin 21-40: Earn $4.00
d. Spin 41-60: Earn $1.00
e. Spin 61-80: Earn $2.00
f. Spin 81-100: Earn $3.00
4. Draw one card from a deck of 52: Depending on the number, suit, or face card, you will get prize4:
a. Suits (multiplier): Club (x1), Diamond (x2), Heart (x3), Spade (x4)
b. Numbers 2-10: Get a deck of cards worth $1.00
c. Number 11 (Jack): Get a game of jacks worth $.50 (the booby prize)
d. Number 12 (Queen): Get an autographed picture of the fair queen worth $2.00
e. Number 13 (King): Get an autographed picture of the fair king worth $2.00
f. Number 14: (Ace): Get $10.00
After counting the number of booby prizes one person may get, use the following scale to award a consolation prize:
a. 1 booby prize: $1.00
b. 2 booby prizes: $2.00
c. 3 booby prizes: $3.00
d. 4 booby prizes: $4.00
As you generate the random numbers (use any method you like), here are suggested variables: