Hello Good night. I'm Beginner and I've received this program to do its due tonight and i'm still having problem doing it. Could someone help me please??
Write a program to continue accepting integer numbers while the number entered is NOT 999. The program should store each number in an array called "numbers" (no more than a 100 numbers will be used). After accepting all the numbers, the program should prompt the user for the operation to be performed.
If the user enters "+" for the operation the program should find the sum of all the numbers as the result, however, if the user enters "x" for the operation, the program should find the product of all the numbers as the result.
Afterwards, if the user entered "+" for the operation, the program should then print all the numbers previously entered followed by the operation in the following manner:
Example: The numbers entered were 3, 5, 10, 999 and the operation entered was "+" :
The sum of 3, 5 and 10 is 18.
If the user entered "x" for the operation, the program should then print the output in the following manner:
Example: The numbers entered were 3,5, 10, 999 and the operation entered was "x":
The product of 3, 5 and 10 is 18.
Finally, if the operation entered was not “+” or “x”, the program should print “You have entered an invalid operation, please run the program and try again.”
very simple program
i shouldn't have to do your whole homework for you
try something first then edit your post with what you have
you should be able to do a switch statement tho
I just started programming to be honest i understand little so far but i'm going to show you what i've been doing so far
#include<iostream>
using namespace std;
int main()
{
//write a program to continue accepting integer numbers while the number entered is not 999.
//the program should store each number in an array called numbers.
int numbers[3]; (6, 12, 10, 999);
//After accepting all the numbers, the program should prompt the user for the operation to be performed.
//if the user enters "+" for the operation the program should find the sum of all the numbers.
//if the user enters "+" for the operation, the program should then print all numbers previously
int product;
int sum;
if ('+'); {
sum = 6 + 12 + 10;
cout<< "sum of all numbers is: \n";
cin >> sum;
}
if ('*'){
product = 6 * 12 * 10;
cout<< "product of all number is: \n";
cin>> product;
}
// Finally, if the operation entered was not "+" or "x", the program should print " You have entered an invalid operation, please run the program and try again."
There's an example of finding the sum of all the values in an array in the tutorial, under the heading Accessing the values of an array http://www.cplusplus.com/doc/tutorial/arrays/
Given the limited time available for completing this assignment, you may need to do a more detailed reading of those pages later. But for now concentrate on the array example, the one with the line