Thread: Help With Miracle C

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    2

    Question Help With Miracle C

    I am having problems with Miracle C. My program compiles and executes, but it does not give me the output that I want it to. The notepad that contains my program information is included as an attachment. The program puts the words Amount of Tax below the words Amount Due, but it does not actually give me the amount of tax. It does tell me how much I spend with tax included. What do I have to do to fix the problem? I need to know sometime today.


  2. #2
    Registered User
    Join Date
    Nov 2006
    Location
    japan
    Posts
    126

    fTotal = ...

    i Dont' understand why you do

    Code:
    fTotal = (fSubTotal * 0.0725); 
    fTotal = (fSubTotal * 0.0725 ) + fSubTotal;
    aren't you repiting something
    Mac OS 10.6 Snow Leopard : Darwin

  3. #3
    Registered User
    Join Date
    Nov 2006
    Location
    japan
    Posts
    126
    also it is not neccesary in this case to use
    Code:
    if () 
    {...
    }
    else 
    if(){...
    }
    if()
    { ...
    }
    with 3 ifs it would be enough
    Code:
     
    if(){
    ...
    }
    if(){
    ...}
    if(){
    ...}
    Mac OS 10.6 Snow Leopard : Darwin

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    thirdchild, I suggest that you format your code such that it has consistent indentation.

    The program puts the words Amount of Tax below the words Amount Due, but it does not actually give me the amount of tax. It does tell me how much I spend with tax included. What do I have to do to fix the problem?
    At a glance, it looks like the problem is simply because you are not actually printing the amount of tax.

    with 3 ifs it would be enough
    No, the code is fine that way. With your suggested change three comparisons will always be performed. With the current code sometimes only one comparison will be performed.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Nov 2006
    Location
    japan
    Posts
    126
    Quote Originally Posted by laserlight View Post
    No, the code is fine that way. With your suggested change three comparisons will always be performed. With the current code sometimes only one comparison will be performed.
    I just tested ... it runs fine without "else"s
    Mac OS 10.6 Snow Leopard : Darwin

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I just tested ... it runs fine without "else"s
    Of course it does, since only one of the three comparisons will evaluate as true, if any do. The difference is purely one of logic and (less importantly in this case) performance. Alternatively, one could use a switch.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    Feb 2008
    Posts
    2

    Question Mircale C Assignment

    I am supposed to calculate and display the the tax amount for the store selected and the total sale amount for that store. The way that I have it, it is only tells me the tax rate and the total amount due. I am supposed to change the program so that it tells me the amount of tax for each sale as well as the tax rate and total amount due. I have messed around with it for a while and cannot figure out how to get it to give me the amount of tax paid for each sale.

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I have messed around with it for a while and cannot figure out how to get it to give me the amount of tax paid for each sale.
    Before messing with the code, mathematically, how would go about doing these calculations?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A Miracle has occurred in the realm of Hot Dogs
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 05-08-2004, 03:18 PM
  2. miracle c?
    By wraith8 in forum C Programming
    Replies: 2
    Last Post: 08-06-2003, 09:27 PM
  3. Replies: 10
    Last Post: 06-26-2003, 08:26 AM
  4. Miracle C [I Need Help With Coloured Text]
    By paulroseby in forum C Programming
    Replies: 5
    Last Post: 09-29-2002, 11:50 AM
  5. miracle c compiler
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 04-22-2002, 10:21 PM