Thread: If statements question.

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    21

    Question If statements question.

    Hello,
    I am having a difficulties with a C++ program involving "if" statements.
    I recieve a syntax error that reads the following:
    grade.cpp: In function `int main()':
    grade.cpp:21: syntax error before `)'
    grade.cpp:44: malformed floating constant
    grade.cpp:48: syntax error at end of input

    I was wondeing if anyone would take a look and see if they saw what I am doing wrong, here is my stuff, THANK YOU!:

    Code:
    //Name: grade.cpp
    #include <iostream>
    int main()
    {
    double x;
    cout << "Please Enter Percentage Rounded to the Nearest Hundredth of a Percent: " << endl;
    cin >> x;
    
    if (x >= 93)
    {cout << "Your Score of " << x << " is an A" << endl;}
    
    if (x <= 92.99 && x >= 90)
    {cout << "Your Score of " << x << " is an A-" << endl;}
    
    if (x <= 89.99 && x >= 87)
    {cout << "Your Score of " << x << " is a B+" << endl;}
    
    if (x <= 86.99 && x >= 83)
    {cout << "Your Score of " << x << " is a B" << endl;}
    
    if (x <= 82.99 && x >= 80)
    {cout << "Your Score of " << x << " is a B-" << endl;)
    
    if (x <= 79.99 && x >= 77)
    {cout << "Your Score of " << x << " is a C+" << endl;}
    
    if (x <= 76.99 && x >= 73)
    {cout << "Your Score of " << x << " is a C" << endl;}
    
    if (x <= 72.99 && x >= 70)
    {cout << "Your Score of " << x << " is a C-" << endl;
    }
    if (x <= 69.99 && x >= 67)
    {
    cout << "Your Score of " << x << " is a D+" << endl;
    }
    if (x <= 66.99 && x >= 63)
    {
    cout << "Your Score of " << x << " is a D" << endl;
    }
    if (x <= 62.99 && x >= 60)
    {
    cout << "Your Score of " << x << " is a D-" << endl;
    }
    if (x <= 59..99)
    {
    cout << "Your Score of " << x << " is a D-" << endl;
    }
    
    clear 0;
    }

  2. #2
    Registered User
    Join Date
    Nov 2006
    Posts
    85
    Try changing

    Code:
    if (x <= 59..99)
    to

    Code:
    if (x <= 59.99)

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    Code:
    if ( x < 59.99 )
    should be a 'F' shouldn't it?

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Btw, it should be std::cout and std::cin unless you have added "using namespace std;".
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. While Statements Question
    By thekautz in forum C++ Programming
    Replies: 4
    Last Post: 11-09-2008, 02:48 PM
  2. Multiple If Statements Question.
    By thekautz in forum C++ Programming
    Replies: 3
    Last Post: 11-07-2008, 03:06 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  5. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 01:36 PM