Modular program mathlab:
Write a program in Matlab that would continuously ask the user for an input between 1 and 6, which would represent the result of rolling a die. The program would then generate a random integer between 1 and 6 and compare its value to the value entered by user.
If the user’s die is larger, it should display, “You got it”
If the user’s die is smaller, it should display, “Nice try”
If the results are the same, it should display, “Awesome”.
The program should ask if the user wants to play another game (to be answered by either ‘Y’ or ‘N’). If the user answers ‘Y’, the game continues. If the user answers ‘N’, the game ends and it will display, “Thank you for playing”.
The program should have a main script named rollingdie.m and calls on the following functions:
All in all a total of 4 script with the mainscript(rollingdie.m) and subscript (inputdie.m,randomizer.m,compdice.m)
Sample run:
>> rollingdie
>> Do you want to play the lovedice game (Y/N)? Y
>> Enter your dice: 4
>> My dice result: 6
>> Nice try
>> Play again (Y/N)? Y
>> Enter your dice: 5
>> My dice result: 3
>> You got it
>> Play again (Y/N)? Y
>> Enter your dice: 3
>> My dice result: 3
>> Awesome
>> Play again? N
>> Thank you for playing
%main script
play=input('Do you want to play the lovedice game (Y/N)?
','s');
while strcmp(play,'Y')
op=inputdie();
d = randomizer();
fprintf('My dice result: %d\n',d)
compdice(op,d);
play=input('Play again (Y/N)? ','s');
end
disp('Thank you for playing')
%functions
function op = inputdie()
op=input('Enter your dice: ');
end
function d = randomizer()
d=randi(6);
end
function compdice(ip,die)
if ip>die
disp('You got it');
elseif ip<die
disp('Nice try');
else
disp('Awesome')
end
end
Modular program mathlab: Write a program in Matlab that would continuously ask the user for an...
Write a C++ game that plays Craps. Craps is a game played with a pair of dice. The shooter (the player with the dice) rolls a pair of dice and the number of spots showing on the two upward faces are added up. If the opening roll (called the ‘come out roll’) is a 7 or 11, the shooter wins the game. If the opening roll results in a 2 (snake eyes), 3 or 12 (box cars), the shooter loses,...
Specification Write a program that allows the user to play number guessing games. Playing a Guessing Game Use rand() function from the Standard C Library to generate a random number between 1 and 100 (inclusive). Prompt the user to enter a guess. Loop until the user guesses the random number or enters a sentinel value (-1) to give up. Print an error message if the user enters a number that is not between 1 and 100. Print an error message...
USE PYTHON ONLY Please write a Python program to let you or the user play the game of rolling 2 dice and win/lose money. Initially, you have 100 dollars in your account, and the dealer also has 100 dollars in his/her account. You would be asked to enter a bet to start the game. If your bet is zero, the game would be stopped immediately. Otherwise, dealer would roll 2 dice and get a number from ( random.randint(1, 6) +...
C++ Part 2: Rock Paper Scissors Game Write a program that lets the user play this game against the computer. The program should work as follows: When the program begins, a random number between 1 and 3 is generated. If the number is 1, the computer has chosen rock. If the number is 2, the computer has chosen paper. If the number is 3, the computer has chosen scissors. Don't display the computer's choice yet. Use a menu to display...
**IN JAVA** Make a Game -Game Strategy The program and the user alternate turns, picking up one, two, or three straws on each turn. The program goes first. The player to pick up the last straw loses. -Game process Your program should start by generating and displaying a random integer (which represents the number of straws) between 10 and 20 inclusive. If this number is 1 more than a multiple of 4, add 1. For example, if the random integer...
IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet....
Write a program in C++ that gives the temperature of earth at a depth. It must be in C++ and follow the information below: Problem description Write a program to take a depth in kilometers inside the earth as input data; calculate and display the temperature at this depth in both degrees Celsius and degree Fahrenheit. The formulas are: Celsius temperature at depth in km: celsius = 10 x depth(km) + 20 Convert celsius to fahrenheit: fahrenheit = 1.8 x...
(Java) Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet. The...
1) Write a MATLAB script to prompt a user to input two numbers, then assess whether the two numbers are equal or not. If the two numbers are equal, display that they are equal in the Command Window. If they are not equal, display that they are not equal in the Command Window. 2) Write a MATLAB script that prompts the user to enter the day of the week using the input function. If the information the user enters is...
Can anyone help me with this java program? We are still very early with lessons so no advanced code please. And if you comment throughout the code that would be incredibly helpful. Thank you Create 2 Java files for this assignment: Die.java and TestDie.java Part 1 - The Die Class The program Design a Die class that contains the following attributes: sides: represents how many sides a dice has. A dice usually has 6 sides but sometimes could have...