Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

My first almost useful program


  • Please log in to reply

#1
akashlee

akashlee

    Member

  • Member
  • PipPipPip
  • 126 posts
review it please
if it sucks... my excuse is that i am 13 and its my first useful program...
my programs name is shift
here is the code for it:


//This program was made to test your speed in mental math
/* Please Email Me At [email protected]*/
//Beginging The Program:
//Thank You!!!
#include <iostream>
#include <string>
using namespace std;
int main ()
{
//Declaring The Variables:
int add1;
int add2;
int add3;
int sub1;
int sub2;
int sub3;
int mult1;
int mult2;
int mult3;
int div1;
int div2;
int div3;
int frac1;
int frac2;
int frac3;
int age;
int year;
string username;
// Intro to the user | The program starts here:
cout << "|SHIFT MATH TEST, VERSION ONE, EASY LEVEL| Hello user! This program tests your knowledge of math:";
cout << "Adding, Subtracting, Multiplying, Dividing and fractions. ";
cout << " Before we begin your test, I would like to know your: ";
//Personal Information:
cout << "Name?";
cin >> username;
cin.ignore ();
cout << "Your name is " << username <<"\n";
cout << "How old are you?";
cin >> age;
cin.ignore ();
cout << "You are " << age <<"\n";
cout << "Good. One last personal question, what year is it now?";
cin >> year;
cin.ignore ();
cout << "It is the year " << year <<"\n";
//The Test:
cout << "I am now done getting your personal informaion. Now on with the test...";
//Additon-
//Add1
cout << "What is 4+34= ";
cin >> add1;
if ( add1 == 38 ) {
cout << "Good! \n";
}
else if ( add1 != 38 ) {
cout << ":tazz:\n"; }
//Add2
cout << "What is 44+32= ";
cin >> add2;
if ( add2 == 76 ) {
cout << "Awesome \n";
}
else if ( add2 != 76 ) {
cout << "Good Try, but not the cigar :)\n"; }
//Add3
cout << "What is 123+234=\n";
cin >> add3;
if ( add3 == 357 ) {
cout << "Well done :)\n";
}
else if ( add3 != 357 ) {
cout << " Ok...:)\n"; }
//Sub1
cout << "What is 10-7=\n";
cin >> sub1;
if ( sub1 == 3 ) {
cout << "Right :help:\n";
}
else if ( sub1 != 3 ) {
cout << " Nope :woot:\n"; }
//Sub2
cout << "What is 32-12=\n";
cin >> sub2;
if ( sub1 == 20 ) {
cout << "Right \n";
}
else if ( sub2 != 3 ) {
cout << " Nope :P\n"; }
//Sub3
cout << "What is 103-21=\n";
cin >> sub3;
if ( sub3 == 82 ) {
cout << "Yes \n";
}
else if ( sub3 != 82 ) {
cout << " No :)\n"; }
//Mult1
cout << "What is 4X3=\n";
cin >> mult1;
if ( mult1 == 12 ) {
cout << "Very good \n";
}
else if ( mult1 != 12 ) {
cout << " Noooooooo\n"; }
//Mult2
cout << "What is 14X3=\n";
cin >> mult2;
if ( mult2 == 42 ) {
cout << "You study, don't you? :help: \n";
}
else if ( mult2 != 42 ) {
cout << " Study More!!! \n"; }
//Mult3
cout << "What is 12X12=\n";
cin >> mult3;
if ( mult3 == 144 ) {
cout << "Yes \n";
}
else if ( mult3 != 144 ) {
cout << " Study More!!! :)\n"; }
//Div1
cout << "What is 25/5= (Note: / means divided by)\n";
cin >> div1;
if ( div1 == 5 ) {
cout << "You study, don't you? \n";
}
else if ( div1 != 5 ) {
cout << " Study More!!!(\n"; }
//Div2
cout << "What is 27/8= (Note: Use remainders, not decimals Example: 2/11= 5.1; where 5 is the whole number and 1 is the remainder)\n";
cin >> div2;
if ( div2 == 3.3 ) {
cout << "You study, don't you? \n";
}
else if ( div2 != 3.3 ) {
cout << " Study More!!! \n"; }
//Div3
cout << "What is 88/9= (Note: Use remainders, not decimals Example: 2/11= 5 R1)\n";
cin >> div3;
if ( div3 == 9.7 ) {
cout << "I bet your mom is proud of you!!!! \n";
}
else if ( div3 != 9.7 ) {
cout << " What would your mom say? \n"; }
cout << "........................................ You are done. Please go back and count the number of : ) and the number of : ( to figure out your score out of 12. \n";
cout << "This is version one. The next versions will have Fractions, questions using algebra and harder questions.\n";
cout << "If you have any questions upon this programs, Shift... please email [email protected] thank you.";
cout << "User Info:\n";
cout << "Name of User is " << username << "\n";
cout << "Age of User is " << age << "\n";
cout << "Year the test was taken... " << year << "\n";
cout << "SHIFT HAS ENEDED... PLEASE TYPE ' QUIT PLEASE ' to end the program. THANK YOU!!!!! ";
cout << "....Made by Adittya Akash Lee....";
//End
cin.ignore ();
cin.get ();
}

review and rate out of 10.... and tell me how to improve it
note emotions of : ) and : ( is missing because the board doesn't allow me to post that much emotions in my post........

Edited by akashlee, 02 January 2006 - 08:08 PM.

  • 0

Advertisements


#2
Hai Mac

Hai Mac

    Member

  • Member
  • PipPipPip
  • 260 posts
Good start, but if you don't mind, few remarks (not because I want to tease you , but it's for your own programming good :) ).
  • Statements like 'else if ( add1 != 38 )' are totally useless, because you can just say 'else'. If add1 is not 38 then it is simply not 38 => use just 'else'
  • You used copy-paste, right? Run the program and try to find where the human error is (look at your Sub2)
  • Don't use so many variables, use one (e.g. answer) and reuse it.
Don't worry, these are just beginner's errors and I made them too, soon you won't do these any more.
That's all for now, otherwise the program is very neatly written, good and useful use of comments and I hope you DO indent, because here in GeeksToGo it is not shown.

I give you 7/10 :tazz:

Edited by Hai Mac, 03 January 2006 - 05:05 AM.

  • 0

#3
akashlee

akashlee

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 126 posts
yeah i noticed the problem in sub2 too.....
but there was another problem in div2 and div3 because i want the answer to be like 5 R3.... which thing should i use for it... like int, string, char?

thanks for the review :tazz: :) :)
  • 0

#4
Hai Mac

Hai Mac

    Member

  • Member
  • PipPipPip
  • 260 posts
I don't know how to do that exactly in C++,but in C you would use a parsed input. But the way you did it is not bad, but the variable you used MUST be FLOAT, not INT.

Otherwise, if you want that "5R3", use a string as you say and then split it into two parts.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP