Question

In: Computer Science

modify this program to either simulate a teacher or used car salesperson. #include <iostream> #include <string>...

modify this program to either simulate a teacher or used car salesperson.

#include <iostream>
#include <string>
using namespace std;
int Menu(string a, string b, string c)
{ int choice =-1;
cout<<" 1)"<<a<<endl;
cout<<" 2)"<<b<<endl;
cout<<" 3)"<<c<<endl;
cout<<" 4) I don't want to talk to you!!"<<endl;
cin>>choice;
return choice;
}
int Money(int x)
{ int c=-1;
cout<<"\n Are you that materialistic? \n";
c = Menu(" No.", " Yes.", " Can we talk about something else?");
if(c == 1|| c ==2 )
c=-1;
else if (c == 3 )
c =3;
return c;
}
int Relationship(int x)
{ int c=-1;
cout<<"\n What is your relationship like with this person?\n";
c = Menu(" Like, my best friend.", " We are not really that close.", " Can we talk about something else?");
if(c == 1|| c ==2 )
c=-1;
else if (c == 3 )
c =3;
return c;
}
int Work(int x)
{ int choice=-1;
cout<<"\n What is going on at your job? \n";
choice = Menu(" The boss is a great!", " I just got a raise.", " There is this really cute collegue.");
if(choice == 1|| choice ==3 )
choice = Relationship(choice);
else if (choice == 2 )
choice = Money(choice);
return choice;
}
int main()
{ int answer=-1;
cout<<"\n Hi! How are you feeling today? \n";
answer = Menu(" Excellent!", " OK.", " Bad.");
do {
if(answer == 1 )
{ cout<<"\n What makes things so good? \n";
answer = Menu(" Your Job?", " Your friend", " Your sister or Brother?");
if(answer == 1 )
answer = Work(answer);
else if (answer == 2 || answer ==3 )
answer = Relationship(answer);
}
else if (answer == 2)
{ cout<<"\n Did something happen? \n";
answer = Menu(" No.", " Yes.", " Can we talk about something else?");
if(answer == 1)
{ cout<<" \n\n I think we need to talk about it. \n\n\n";
answer = -1;
}
else if (answer == 2)
{ cout<<"\n Did I do something to upset you?\n";
answer =Menu(" No.", " Yes.", " Let's talk about something else?");
if(answer == 1)
answer =2;
else if (answer == 2)
answer =3;
else if (answer==3)
answer =-1;
}
else if (answer==3)
answer =-1;
}
else if (answer == 3)
{ cout<<"\n I am sorry to hear that. Can you tell me more? \n";
answer = Menu(" No.", " Yes.", " Let's talk about something else?");
if(answer == 1)
{ cout<<" \n\n I think we need to talk about it. \n\n\n";
answer = -1;
}
else if (answer == 2)
answer =2;
else if (answer==3)
answer =-1;
}
else if (answer == 4)
cout<<"OK. Have a nice day.\n\n\n";
else
{ cout<<"\n How do you feel about that?"<<endl<<endl;
answer = Menu( " Very happy."," Terrible.", " Let's talk about something else?");
}
} while (answer != 4);
cout<<" Bye!\n\n\n\n";
system("PAUSE");
return 0;
}

Solutions

Expert Solution


Related Solutions

Modify the program to double each number in the vector. #include <iostream> #include <vector> using namespace...
Modify the program to double each number in the vector. #include <iostream> #include <vector> using namespace std; int main() { const int N=8; vector<int> nums(N); // User numbers int i=0; // Loop index cout << "\nEnter " << N << " numbers...\n"; for (i = 0; i < N; ++i) { cout << i+1 << ": "; cin >> nums.at(i); } // Convert negatives to 0 for (i = 0; i < N; ++i) { if (nums.at(i) < 0) {...
#include<iostream> #include<string> #include<fstream> #include<vector> /*HW: Create two more functions, Modify the posted grade example that uses...
#include<iostream> #include<string> #include<fstream> #include<vector> /*HW: Create two more functions, Modify the posted grade example that uses dynamic arrays and file I/O to include the following: -Use vectors -read from values from the file and store them in the vector. Modify the function getGrades Extend the program to also include the following features: -A menu option that allows the user to add more students and there grades. Assume the number of quizzes stay the same based on the value read from...
this is cahce memory related c program....and not working or running properly??????? #include <iostream> #include <string>...
this is cahce memory related c program....and not working or running properly??????? #include <iostream> #include <string> #include <vector> #include <iomanip> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; int cash_type, block_size, cash_size,number_of_blocks=0;; int compulsry_misses=0, capcity_misses=0, conflict_misses=0; #define DRAM_SIZE (64*1024*1024) unsigned int m_w = 0xABABAB55; /* must not be zero, nor 0x464fffff */ unsigned int m_z = 0x05080902; /* must not be zero, nor 0x9068ffff */ unsigned int rand_() { m_z = 36969 * (m_z & 65535) + (m_z >>...
C++ Program - Arrays- Include the following header files in your program:     string, iomanip, iostream Suggestion:...
C++ Program - Arrays- Include the following header files in your program:     string, iomanip, iostream Suggestion: code steps 1 thru 4 then test then add requirement 5, then test, then add 6, then test etc. Add comments to display assignment //step 1., //step 2. etc. This program is to have no programmer created functions. Just do everything in main and make sure you comment each step so I can grade more easily. Also, this program will be expanded in Chapter...
#include <iostream> #include <string> #include <iomanip> #include <fstream> using namespace std; struct Product {    string...
#include <iostream> #include <string> #include <iomanip> #include <fstream> using namespace std; struct Product {    string itemname;    int id;    string itemcolor;    double cost; }; void fillProduct(Product[10], int& );//read data from a file and store in an array void writeProduct(Product[10], int);//write the array into a file void writeBinary(Product[10], int);//write the array into a file in binary mode void printbinary(Product[10], int);//read data from the binary file and print int main() {    Product myList[10];    int numItems = 0;...
Read Ch. 3. Using the C++ editor, type the following program: #include <iostream> #include <string> using...
Read Ch. 3. Using the C++ editor, type the following program: #include <iostream> #include <string> using namespace std; int main () {        //declarations string name;        //input cout <<"Enter your first name" << endl;        cin >> name;        //output        cout << "Hello " << name << "! " << endl;        return 0; } Compile and run. What does the cin statement do? What does the cout statement do? Is name a variable or a constant? What...
A used car salesperson claims that the probability of he selling a used car to an...
A used car salesperson claims that the probability of he selling a used car to an individual looking to purchase a used car is 70% and this probability does not vary from individual to individual. Suppose 5 individuals come to speak to this salesperson one day. If his belief is correct, The probability (to 4 decimal places) that he will sell a car to the first individual he speaks to is ______ The probability (to 4 decimal places) that he...
Complete the following TODO: parts of the code in C++ #include <iostream> #include <string> #include <limits>...
Complete the following TODO: parts of the code in C++ #include <iostream> #include <string> #include <limits> #include <vector> using namespace std; // // CLASS: NODE // class Node{ public: int value = 0; // our node holds an integer Node *next = nullptr; // our node has a pointer to the next Node Node(int i){ // contructor for our Node class value = i; // store a copy of argument "i" in "value" next = nullptr; // be sure next...
#include <iostream> #include <string> #include <sstream> using namespace std; int main() { string userInput; getline(cin, userInput);...
#include <iostream> #include <string> #include <sstream> using namespace std; int main() { string userInput; getline(cin, userInput); // Declaring base int N = 30; if (userInput.length() > 10) { cout << 0 << endl; } else { int finalTotal = 0; //Iterates through userInput for(int i = 0; i < 10; i++){ char convertedInput = userInput[i]; // ASCII decimal value of each character int asciiDec = int(convertedInput); //Casts char value from input to int value stringstream chr; chr << convertedInput; int...
Are my codes correct? #include <iostream> #include <string> #include <cassert> #include <cctype> #include <cstring> #include <stdio.h>...
Are my codes correct? #include <iostream> #include <string> #include <cassert> #include <cctype> #include <cstring> #include <stdio.h> #include <ctype.h> #include<fstream> int locateMinimum( const std::string array[ ], int n ){    if(n <= 0){    return -1;    }    else{    int minInd = 0;    for(int i = 0; i < n; ++i){    if(array[i] < array[minInd]){    minInd = i;    }    }    return minInd;    } } int countPunctuation( const std::string array[], int n) { int...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT