Help With Miracle C

This is a discussion on Help With Miracle C within the C Programming forums, part of the General Programming Boards category; I am having problems with Miracle C. My program compiles and executes, but it does not give me the output ...

  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.

    Attached Files Attached Files

  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
    22,275
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    22,275
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    22,275
    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?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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, 04:18 PM
  2. miracle c?
    By wraith8 in forum C Programming
    Replies: 2
    Last Post: 08-06-2003, 10:27 PM
  3. Replies: 10
    Last Post: 06-26-2003, 09:26 AM
  4. Miracle C [I Need Help With Coloured Text]
    By paulroseby in forum C Programming
    Replies: 5
    Last Post: 09-29-2002, 12:50 PM
  5. miracle c compiler
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 04-22-2002, 11:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21