Jul 5, 2011 at 9:41pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
#include <iostream.h>
int main ()
{
int a;
int b;
int c;
int d;
int e;
cout << "Input the answers to these math problems:" << endl;
cout << "#1. What is 100 squared?" << endl;
cin >> a;
if (a == 10000) {
cout << "10000 is correct." << endl;
}
else {
cout << a << " is incorrect." << endl;
system("pause" );
//--------------------------------------------------------------------
cout << "#2. What is 15 cubed?" << endl;
cin >> b;
if (b == 3375) {
cout << "3375 is correct." << endl;
}
else {
cout << b << " is incorrect" << endl;
}
system("pause" );
//-----------------------------------------------------------------
cout << "#3. What is the square root of 4900?" << endl;
cin >> c;
if (c == 70) {
cout << "70 is correct." << endl;
}
else {
cout << c << " is incorrect" << endl;
}
system("pause" );
//-----------------------------------------------------------------------
cout << "#4. What is 12 multiplied by 12.5?" << endl;
cin >> d;
if (d == 150) {
cout << "150 is correct." << endl;
}
else {
cout << d << " is incorrect" << endl;
}
system("pause" );
//----------------------------------------------------------------------------
cout << "#5, last question. What is 6 cubed minus 200?" << endl;
cin >> e;
if (e == 16) {
cout << "16 is correct!" << endl;
}
else {
cout << e << " is incorrect." << endl;
}
cout << "The test is over! Lets review your score!" << endl;
if (a == 10000) {
cout << "You got #1 right. 1 Point." << endl;
}
else {
cout << "You got #1 wrong." << endl;
}
if (b == 3375) {
cout << "You got #2 right. 1 Point." << endl;
}
else {
cout << "You got #2 wrong" << endl;
}
if (c == 70) {
cout << "You got #3 right. 1 Point" << endl;
}
else {
cout << "You got #3 wrong." << endl;
}
if (d == 150) {
cout << "You got #4 right. 1 Point." << endl;
}
else {
cout << "You got #4 wrong. 1 Point." << endl;
}
if (e == 16) {
cout << "You got #5 right. 1 Point." << endl;
}
else {
cout << "You got #5 wrong." << endl;
system("pause" );
}
Im new, I just started yesterday, and can you check this for the 2 errors detected, or maybe a little help?
EDIT: This is ment to be a simple 5-Question math test.
Last edited on Jul 5, 2011 at 9:42pm UTC
Jul 5, 2011 at 9:43pm UTC
So what lines did your compiler point at with the output?
Jul 5, 2011 at 9:44pm UTC
If you mean errors, it repeatedly mentioned:
C:\Temp\GABESCODES1\C++ TEsting\EVEN MORE C++\mathtest1.cpp:91: error: expected `}' at end of input
C:\Temp\GABESCODES1\C++ TEsting\EVEN MORE C++\mathtest1.cpp:91: error: expected `}' at end of input
Execution terminated
(The gabescodes and such is my folders.)
Jul 5, 2011 at 9:52pm UTC
I think you confused yourself with how you have the brackets set up. After lining them up (in the style that I prefer), you were missing a few closing brackets. More comments in the code below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
#include <iostream>
using namespace std;
int main ()
{
int a;
int b;
int c;
int d;
int e;
cout << "Input the answers to these math problems:" << endl;
cout << "#1. What is 100 squared?" << endl;
cin >> a;
if (a == 10000)
{
cout << "10000 is correct." << endl;
}
else
{
cout << a << " is incorrect." << endl;
} // <-- This Was Missing
cout << "#2. What is 15 cubed?" << endl;
cin >> b;
if (b == 3375)
{
cout << "3375 is correct." << endl;
}
else
{
cout << b << " is incorrect" << endl;
}
cout << "#3. What is the square root of 4900?" << endl;
cin >> c;
if (c == 70)
{
cout << "70 is correct." << endl;
}
else
{
cout << c << " is incorrect" << endl;
}
cout << "#4. What is 12 multiplied by 12.5?" << endl;
cin >> d;
if (d == 150)
{
cout << "150 is correct." << endl;
}
else
{
cout << d << " is incorrect" << endl;
}
cout << "#5, last question. What is 6 cubed minus 200?" << endl;
cin >> e;
if (e == 16)
{
cout << "16 is correct!" << endl;
}
else
{
cout << e << " is incorrect." << endl;
}
cout << "The test is over! Lets review your score!" << endl;
if (a == 10000)
{
cout << "You got #1 right. 1 Point." << endl;
}
else
{
cout << "You got #1 wrong." << endl;
}
if (b == 3375)
{
cout << "You got #2 right. 1 Point." << endl;
}
else
{
cout << "You got #2 wrong" << endl;
}
if (c == 70)
{
cout << "You got #3 right. 1 Point" << endl;
}
else
{
cout << "You got #3 wrong." << endl;
}
if (d == 150)
{
cout << "You got #4 right. 1 Point." << endl;
}
else
{
cout << "You got #4 wrong. 1 Point." << endl; // <-- Check This Line
}
if (e == 16)
{
cout << "You got #5 right. 1 Point." << endl;
}
else
{
cout << "You got #5 wrong." << endl;
} // <-- This Was Missing
}
Last edited on Jul 5, 2011 at 9:53pm UTC
Jul 5, 2011 at 9:55pm UTC
Thanks man, that made it work.
EDIT:
It runs through, and system("pause"); is throwing some more errors. The ending part is lost.
Last edited on Jul 5, 2011 at 9:58pm UTC