Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Activity 1 Create a class named Coin with the following fields & methods - sideU

ID: 3673385 • Letter: A

Question

Activity 1

Create a class named Coin with the following fields & methods -

sideUp – an instance variable indicating the face value of the coin (e.g., “Heads” or “Tails”)

coinValue – an instance variable holding the actual coin value – $0.25 (quarter,) $0.10 (dime) and $0.05 (nickel)

Coin() –

A no-arg constructor

randomly assign the side of the coin that is facing up (“Heads” or “Tails”)

initialize it as a quarter

Coin(amount) –

constructor to set the coin value as quarter, dime or nickel

randomly assign the side of the coin that is facing up

Coin(amount, face) –

constructor to set the coin as quarter, dime or nickel

set its sideUp to the face value

toss()

tossing the coin

getSideUp() –

getter function

returns the value of the sideUp field

getCoinValue()

Activity 2

Design & implement a Java class named Uber (taxi-like service) with the following features -Schedule a pickup service by specifying

Name of customer

Pickup date & time

Number of passengers (to be picked up)

Distance (destination in term of miles, to make the class easier to implement)

Compute the total cost of a trip and display cost to console

$2 per mile for the 1st two passengers

$5 per additional passenger (starting with the 3rd passenger)

Add one additional requirement (feature) of your choice (for the class)

See your course instructor if you need help on this

Include 1 paragraph in your write-up to discuss it. What’s it?

This activity allows each student to design and implement a class from the ground up.

Activity 3

Implement a Driver class with the following functionalities –main()Menu-driven application allowing an user to –Toss a coin for a specified number of times & display its outcome

For example, an user could choose to toss a coin for 20 times

display the actual outcome: 12 “heads” & 8 “tails” (this is an example only)

Play the “Price-is-Right” gameStart a game with $0 in a jackpot as the game begins

Simulate a randomly tossing one of three coins (quarter, dime & nickel)

Add the value of the selected coin to the jackpot (e.g., $0.05, $0.10 or $0.25)

Repeat this process until

A maximum of 4 tosses has occurred (game over)

Total of more than $0.75 (User won!)

Schedule a ride for one of three Uber cars (4, 5 & 6 passengers)

A car can only be scheduled if it’s available

Display scheduled info to console once a car has been scheduled

Allow user to continue using this program for as long as they choose to


Outputs: http://postimg.org/image/5ypxkimlx/

http://postimg.org/image/e2y1p9911/

http://postimg.org/image/61eel3fn9/

http://postimg.org/image/72a1wh791/

http://postimg.org/image/vrpsgvks5/

Explanation / Answer

The sideUP field will hold either “heads” or “tails” indicating the side of the coin that is facing up.
The constructor randomly determines the side of the coin that is facing up (“heads” or “tails”) and initialized the sideUP field accordingly.
toss method that simulates the tossing of the coin. When the toss method is called, it randomly determines the side of the coin that is facing up and sets the sideUP field accordingly.
getSideUp method return the value of the sideUp field.

activity 2

activity 3:

public class coin
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote