Sale!

CSC150 Assignment 7 solved

$30.00 $18.00

Original Work ?

Download Details:

  • Name: AssignmentSeven-ybatko.zip
  • Type: zip
  • Size: 44.30 KB

Category: Tag: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

Simple dice game simulation

Write a program that simulates a simple dice game between the computer and the user. When the program is run, it should randomly select a number between 1 and 6 for both the user and the computer. After selecting these numbers, the program should print out the numbers and determine who the winner is. The winner is the one who has the higher number. If both numbers are the same, then it is a tie.

The program should include multiple runs of the game. It should ask the user whether he/she wants to play again after each run. If the user enters ‘y’ or ‘Y’, then the game should run again. If the user enters ‘n’ or ‘N’, then the program should print out a message thanking the user for playing and then terminate. You should use a loop to implement this feature. You should also use the random number generator to generate the numbers for the dice rolls.

Sample Runs:

Let’s play a game of dice! We both roll and whoever is higher after 3 runs wins! Do you want to play? (y/n) y

Your number is: 4 Computer’s number is: 3

Computer Wins!

The score is: You: 0 Computer: 1

Do you want to play again? (y/n) y

Your number is: 2 Computer’s number is: 5

Computer Wins!

The score is: You: 0 Computer: 2

Do you want to play again? (y/n) y

Your number is: 3 Computer’s number is: 2

You Win!

The score is: You: 1 Computer: 2

Do you want to play again? (y/n) y

Your number is: 1 Computer’s number is: 2

Computer Wins!

The score is: You: 1 Computer: 3

Do you want to play again? (y/n) y

Your number is: 5 Computer’s number is: 5

It’s a tie!

The score is: You: 1 Computer: 3

Do you want to play again? (y/n) n

That was the best match! I won! Thank you for playing with me!

Notes:

  1. The program must compile without syntax errors. In the best case 50% of the assignment points will be deducted, and in the worst case 0 points automatically.
  2. To get full credit on this assignment, your program must solve the assignment problem correctly.
  3. Please add comments to the source code. Your program should have a reasonable amount of comments.
  4. At the very beginning of the file, there should be a block comment containing the student name, EUID, class section, email address, and date.
  5. Follow the programming style and guidelines discussed in class, such as using meaningful variable names, proper indentation, and including comments