RandomGame.cpp (2pt)
Write a program that asks the user to enter his/her name. Then begin a do while loop that asks the user to enter a number between 1 and 10.
Have the random number generator produce a number 1 and 10.
Display the user’s name and both numbers to the screen.
Compare the two numbers and report if the entered number is greater than, less than, or the same as the generated number.
Ask the user if he/she’d like to go again.
Say goodbye when finished playing.
If the user enters a number out of range, display an out of range message, then display the “ask again” code.
Sample run
Please enter your name: Tony
Please enter a number between 1 and 10: 8
Tony, you entered 8 and the computer generated 8.
Your number is the same.
Go again? yes/no: yes
Please enter a number between 1 and 10: 7
Tony, you entered 7 and the computer generated 4.
Your number is greater than the computer's number.
Go again? yes/no: yes
Please enter a number between 1 and 10: 12
Tony, your number is out of range.
Go again? yes/no: no
Goodbye for now.
!!!!! Please C++.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
string name, choice = "yes";
cout<<"Please enter your name: ";
cin >>name;
int n;
srand (time(NULL));
do{
int randNum = rand() % 10 + 1;
cout<<"Please enter a number between 1 and 10: ";
cin >> n;
if(n>0 && n <=10){
cout<<name<<", you entered "<<n<<" and the
computer generated "<<randNum<<"."<<endl;
if(n > randNum){
cout<<"Your number is greater than the computer's
number."<<endl;
}
else if(n < randNum){
cout<<"Your number is less than the computer's
number."<<endl;
}
else{
cout<<"Your number is the same."<<endl;
}
}
else{
cout<<name<<", your number is out of
range."<<endl;
}
cout<<"Go again? yes/no: ";
cin >> choice;
}while(choice=="yes");
return 0;
}
Output:
sh-4.2$ g++ -o main *.cpp
sh-4.2$ main
Please enter your name: Tony
Please enter a number between 1 and 10: 5
Tony, you entered 5 and the computer generated 1.
Your number is greater than the computer's number.
Go again? yes/no: yes
Please enter a number between 1 and 10: 6
Tony, you entered 6 and the computer generated 6.
Your number is the same.
Go again? yes/no: no
RandomGame.cpp (2pt) Write a program that asks the user to enter his/her name. Then begin a...
Write a console-based program ( C # ) that asks a user to enter a number between 1 and 10. Check if the number is between the range and if not ask the user to enter again or quit. Store the values entered in an array. Write two methods. Method1 called displayByVal should have a parameter defined where you pass the value of an array element into the method and display it. Method2 called displayByRef should have a parameter defined...
Starting Out with C++ (9th Edition) Chapter 4, Problem 7PCWrite a program that asks the user to enter a number of seconds.• There are 86400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86400, the program should display the number of days in that many seconds.• There are 3600 seconds in an hour. If the number of seconds entered by the user is less than 86400, but is greater...
write in python idle Write full program that asks the user to enter his/her name then repeatedly ask to enter the temperature in Fahrenheit and convert it to Celsius, the program should then prompt the user if he/she wants to continue or exit the program. The formula for conversion is: °C = (°F - 32) x 5/9 The program should use a function for the conversion. An Example of a sample run should appear on the screen like the text...
23. Personal Weeb Page GeneratorWrite a program that asks the user for his or her name, and then asks the user to enter a sentence that describes him or herself. Here is an example of the program's screen:Enter your name: Julie Taylor [Enter]<html> <head> </head> <body> <center> <h1>Julie Taylor</h1> </center> <hr /> I am a computer science major, a member of the Jazz club, and I hope to work as a mobile app developer after I graduate. <hr /> </body> </html>Describe yourself: I am a computer science major, a member of theOnce the user has entered the requested input, the program should create an HTML file,...
Write python program using IDLE Write a full program that asks the user to enter his/her name then repeatedly ask to enter the temperature in Fahrenheit and convert it to Celsius, the program should then prompt the user if he/she wants to continue or exit the program. The formula for the conversion is: °C = (°F - 32) x 5/9 The program should use a function for the conversion. An Example of a sample run should appear on the screen...
2. Write a C++ program that asks the user to enter a integer between 1 and 10. Continue to prompt the user while the value entered does not fall within the range. When the user is successful display a congratulatory message. Save file as OneToTen.
***** JAVA ONLY ***** Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad to create a simple file that can be used to test the program. ***** JAVA ONLY *****
Write a java program that asks the user to enter an integer. The program should then print all squares less than the number entered by the user. For example, if the user enters 120, the program should display 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100.
Write a program that asks the user to enter a string and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the string. python programming
1. Write a program to add positive numbers. Ask the user to enter numbers greater than zero. If a 0, is entered stop requesting numbers and display the total. If a number is entered that is less than 0, display the message ‘Number must be greater than 0’, then ask for another number to be entered. Repeat until a number greater than 0 or 0 is entered. use math lab so I can copy the answers