#include <iostream>
#include <cstdlib>
#include <time.h>
#include <string>
using namespace std;
int main()
{
srand(time (0));
int number, guess, response, reply;
int score = 0
number = rand() % 100 + 1;
do {
do {
cout << "Enter your guess ";
cin >> guess;
score++;
if (guess < number)
cout << guess << " is too low! Enter a higher number. ";
else if (guess > number)
cout << guess << " is too high! Enter a lower number. ";
else
cout << guess << " is the correct number! \n";
cout << "Congratulations! You won the High/Low Game \n!";
cout << "Your score is " << score;
} while (guess != number);
cout << "Would you like to submit your score to the high score board? \n";
cout << "Enter 1 for YES or 0 for NO. ";
cin >> reply;
if (reply == 1)
{
string first_name, last_name;
cout << "Please enter your first name ";
cin >> first_name;
cout << "\n Please enter your last name ";
cin >> last_name;
}
cout << "Would you like to play again? \n";
cout << "Enter 1 for YES or 0 for NO. ";
cin >> response;
} while (response == 1);
return 0;
}
can someone create a flowchart for this code? thank you
#include <iostream> #include <cstdlib> #include <time.h> #include <string> using namespace std; int main() { srand(time (0));...
Find and fix errors #include <iostream> #include <cstdlib> #include <ctime> using namespace std; const int MIN = 1; const int MAX = 10; int getRandom(int low, int high); int main() { int random_num = 0; int player_num; int tries; int seed = static_cast<int>(time(0)); bool guessed = false; srand(seed); // call the getRandom function below tries = 4; while ( tries > 0 && !guessed ) { cout << "Enter a number within the range 1 to...
#include <iostream> #include <string> using namespace std; int main() { int number; int sum = 0; while(true) { cout << "Please enter a number between 1 and 11: "; cin >> number; if (number >= 1 && number <= 11) { cout << number << endl; sum = sum + number; //only add the sum when number is in range: 1-11, so add wthin this if case } else { cout << number << endl; cout << "Out of range;...
Time.cpp: #include "Time.h" #include <iostream> using namespace std; Time::Time(string time) { hours = 0; minutes = 0; isAfternoon = false; //check to make sure there are 5 characters if (//condition to check if length of string is wrong) { cout << "You must enter a valid military time in the format 00:00" << endl; } else { //check to make sure the colon is in the correct...
#include<iostream> #include<cstdlib> using namespace std; int main() { // create array of size 20 int arr[20]; int i; cout<<"scores : "; for( i = 0 ; i < 20 ; i++ ) { // generate a random number i range 70 - 100 an add it to arr arr[i] = rand() % 31 + 70; cout<<arr[i]<<" "; } // store the total score int total = 0;...
Consider the following C++ program: #include <iostream> #include <cstdlib> using namespace std; int main int n =0; int i = 0; cout << "Please enter a strictly positive number:"; cin >> n if (n <= 0) exit(EXIT_FAILURE) while (n > 1) n-n/2; i << endl; cout"Output:" return 0; Answer the following questions: What is the output of the program for each of the following values of n: -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9? What does...
#include <iostream> #include <sstream> #include <string> using namespace std; int main() { const int index = 5; int head = 0; string s[index]; int flag = 1; int choice; while (flag) { cout << "\n1. Add an Item in the Chores List."; cout << "\n2. How many Chores are in the list."; cout << "\n3. Show the list of Chores."; cout << "\n4. Delete an...
Convert to use functions where possible #include<iostream> #include<string> using namespace std; int main() { string first, last, job; double hours, wages, net, gross, tax, taxrate = .40; double oPay, oHours; int deductions; // input section cout << "Enter First Name: "; cin >> first; cout << "Enter Last Name: "; cin >> last; cin.ignore(); cout << "Enter Job Title: "; getline(cin, job); cout << "Enter Hours Worked:...
#include <fstream> #include <iostream> #include <cstdlib> using namespace std; // Place charcnt prototype (declaration) here int charcnt(string filename, char ch); int main() { string filename; char ch; int chant = 0; cout << "Enter the name of the input file: "; cin >> filename; cout << endl; cout << "Enter a character: "; cin.ignore(); // ignores newline left in stream after previous input statement cin.get(ch); cout << endl; chcnt = charcnt(filename, ch); cout << "# of " «< ch« "'S:...
please help me fix the error in here #include<iostream> #include <string> using namespace std; string getStudentName(); double getNumberExams(); double getScoresAndCalculateTotal(double E); double calculateAverage(double n, double t); char determineLetterGrade(); void displayAverageGrade(); int main() { string StudentName; double NumberExam, Average, ScoresAndCalculateTotal; char LetterGrade; StudentName = getStudentName(); NumberExam = getNumberExams(); ScoresAndCalculateTotal= getScoresAndCalculateTotal(NumberExam); Average = calculateAverage(NumberExam, ScoresAndCalculateTotal); return 0; } string getStudentName() { string StudentName; cout << "\n\nEnter Student Name:"; getline(cin, StudentName); return StudentName; } double getNumberExams() { double NumberExam; cout << "\n\n Enter...
#include <iostream> #include <cstdlib> using namespace std; int **dynArray(int row, int cols) { int **myPtr; int lab[4]; myPtr = new int *[row]; for(int i = 0; i < row; i++) myPtr[i] = new int[lab[i]]; for(int i = 0; i<row ; i++) if(myPtr[i] == 0) cout<<"empty"; return myPtr; } void getinput(int ID,int &Station,int &labnumb) { cout<<" Enter your ID number: "<<endl; cin>>ID; cout<<" Enter your station number: "<<endl; cin>>Station; cout<<" Enter your lab number: "<<endl; cin>>labnumb; return; } void logout(int ID,int...