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

I need a basic c++ program that will do this. First it will ask the user to ente

ID: 3639798 • Letter: I

Question

I need a basic c++ program that will do this.

First it will ask the user to enter his house number.

So let say user enters 8504

Next it adds those numbers together

So 8+5+0+4 = 17

Then it adds the results together

1+7=8

Then it checks a table and couts the results.

The table is
1 = Bing
2 = for you
3,4,5,6 = normal
7 = Heaven
8 = Faith
9 = Fine

so in this case since the answer was 8 it couts Faith

Last thing I need it to ask me if I want to enter another house number like a yes/no question if enter yes it ask me house number again if I enter no it terminates the program.

It can use arrays if that is what it needs.

Explanation / Answer

basically the result from repeatedly adding up digits until you get only one digit is the remainder of that number divided by 9. Since it is modulus of 9 so it cannot have result 9, so "0" is the result 9.

since you don't require that I must implement a function which actually adds up digits, I will use modulus instead.

#include <iostream>
using namespace std;

int main()
{
   //LOCAL DECLARATIONS
   int num;
   char response = 'y';

   //PROCEDURES
   while (toupper(response) == 'Y')
   {
      cout << "Enter your house number: ";
      cin >> num;

      if (num % 9 == 1)
         cout << "Bing";
      else if (num % 9 == 2)
         cout << "For you";
      else if (num % 9 < 7 && num % 9 > 2)
         cout << "Normal";
      else if (num % 9 == 7)
         cout << "Heaven";
      else if (num % 9 == 8)
         cout << "Faith";
      else    //num % 9 == 0 means the result from adding up digits is 9
         cout << "Fine";
      cout << endl;

      cout << "Do you want to enter another house number?(y/n) ";
      cin >> response;
      cout << endl;
   }

   cout << endl;
   cin.ignore();
   cin.get();
   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