Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need this c++ program in a simple way and please include return0 and regular s

ID: 3837839 • Letter: I

Question

I need this c++ program in a simple way and please include return0 and regular simple things

One stormy night, as Dionne worked diligently on her Computer Programming labs, a bolt of lightening struck the house. The power surge raced through her computer, causing it to emit a strange glow. A strange new program appeared on her computer called "psychic". Dionne told all her friends that this program was capable of predicting the future. If they wanted to use the program, for a small fee, they could download it from her web site.

Objective - To write a program that will predict the future

Method - 1. Use the main procedure to

Prompt the user for his/her lucky number. Use this number as input to the srand function found in cstdlib

Prompt the user for which life topic he wishes his predictions based.  Based on the user's response call one of three functions. Suggestions are love, finance, and school, but you may use three of your own choosing. Use a nested if-else statement to control which function is called.

2. Each function will

Call the rand function

Use value generated by the rand function and modulo division as the selector expression in a switch statement.

The switch statement will print out the predictions.

Allow for five different predictions per function.

3. Prompt the user to see if they want another prediction. Keep executing the program until the user tells you to quit.  Make sure that you code for all possible user inputs, including wrong ones.

Explanation / Answer

// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

string school(int number)
{
   switch (number)
   {
   case 0: return "you will be punished in school";
   case 1: return "you will be appriciated in school";
   case 2: return "you will get lot of homework";
   case 3: return "you may not go to school";
   }
}
string finance(int number)
{
   switch (number)
   {
   case 0: return "you will spend more than usual";
   case 1: return "you will get surprise reward";
   case 2: return "you will be in money crisis";
   case 3: return "you may not get sufficient pocket money";
   }
}
string love(int number)
{
   switch (number)
   {
   case 0: return "lucky in love";
   case 1: return "unlucky in love";
   case 2: return "You will find new love";
   case 3: return "You will be disheartened";
   }
}


int main()
{  
   int luckyNumber;
   string topic;
   string luckOutput;
   cout << "Enter your lucky number";
   cout << " ";
   cin >> luckyNumber;
   cout << "your lucky number is " << luckyNumber << endl;
   srand(luckyNumber);

   while (1)
   {
       cout << "Enter the topic you wish the predictions. Choices are love, finance, and school. Press 0 to exit" << endl;
       cin >> topic;
       //getline(cin, topic);
       if (topic == "love")
       {
           luckOutput = love(rand()%4);
           cout << "Your luck of the day in Love --- " << luckOutput << endl;
       }
       else if (topic == "finance")
       {
           luckOutput = finance(rand() % 4);
           cout << "Your luck of the day in Finance --- " << luckOutput << endl;
       }
       else if (topic == "school")
       {
           luckOutput = school(rand()%4);
           cout << "Your luck of the day in School --- " << luckOutput << endl;

       }
       else if (topic == "0")
       {
           return 0;
       }
       else
       {
           cout << "bad choice. Try Again" << endl;
       }
   }

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote