Hello,

I am trying to figure out this program on how to make it loop if Y is pressed and exit when N is pressed at the end of the program. The other problem I'm having is that this program can not have any decimals or negatives in it when the child enters the numbers. The last problem I'm having is that where the "Add _ together _ times and If I enter 2 2 it will give me 2+2+2+2=4 and the result will give me 2*2=4. The result part I have with out a problem...but its the expanding and taking down on the number of times the + signs shows up to give the answer to a child in simple form. The follow is the output for this program (below is the code I have so far):

(clear screen if Y is pressed to start over)
Welcome to the Multiplication Assistant

What is the 1st number? (example 2)<-- (I'm just showing what i'm getting right now for answers if I enter these numbers in)
what is the 2nd number? (example 2)<--

Add _(2) together _(2) times 2+2+2+2=4 <--(this is a problem...its not supppose to do that and I'm not sure how to fix or write it)
Result 2*2=4

Would you like to try again (Y/N)?

Can someone please help me out with this?

Thank you so much!!
ethompson

/*Multiplication Assistant*/
//Program Name: Program7.CPP

#include <iostream>
#include <string>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

using namespace std;

int main()
{

double mult; // multiplier
double multand; //multiplicand
double result; //result
char response; //response

cout<<"Welcome to the Multiplication Assistant";
cout<<endl<<endl;

cout<<"What is the 1st number? ";
cin>>multand;

cout<<"What is the 2nd number? ";
cin>>mult;
cout<<endl;

[B]result = multand * mult;

{if ((multand<=32767) && (mult<=32767));

cout<<"Add "<<multand<<" together "<<mult<<" times ";
cout<<multand<<" + "<<multand<<" + "<<multand<<" + "<<multand<<" = "<<result;
cout<<endl;[/B]

cout<<"Result ";
cout<<mult<<" * "<<multand<<" = "<<result;
cout<<endl<<endl;


[B]response =='Y' || 'N';
cout<<"Would you like to try another (Y/N)? ";
cin>>response;
cout<<endl;[/B]

system("CLS");

else if ((multand>32767)&&(mult>23767));
cout<<"The number you entered is to high, please try again"<<endl;
} 

cin.get();
cin.get();

return 0;
}
Member Avatar for iamthwee

Have you tried constructing a flow chart for your program? Flow charts are always useful especially for new commers.

yes, but I'm just having a heck of a time trying to understand the loops and the way to write them as well . I understand what a loop does, in simple form...I just don't know how to write it the way I want it to work adn what type of loop I want. Also, I have NO clue how to make the addition show part for a child to see how this works to collapse or expand. I am not even sure what code to use to make that even work.

First thing you need to do is clean up your formatting so you (and we) can see your program flow. After every { indent 4 spaces. When you get to the } unindent.

Look up the syntax for this statement:

if ((multand<=32767) && (mult<=32767));

If this and that -- do nothing. The ; ends the statement. Do you want to execute something?


You claim

Add _(2) together _(2) times 2+2+2+2=4 <--(this is a problem...its not supppose to do that and I'm not sure how to fix or write it)

I assume you mean 2+2+2+2=4
Look at your code:

cout<<"Add "<<multand<<" together "<<mult<<" times ";
cout<<multand<<" + "<<multand<<" + "<<multand<<" + "<<multand<<" = "<<result;
cout<<endl;

How many times do you output multand?


What is this line supposed to do?

response =='Y' || 'N';

I think I know what you are trying to do, but maybe you should explain this line.

system("CLS");

Remove this -- it's only in your way at the moment. If you really think you need it, add it when the program is running.

else if ((multand>32767)&&(mult>23767));

Same as the above if statement

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.