help with a program for school

This is a discussion on help with a program for school within the C++ Programming forums, part of the General Programming Boards category; Is it Code: total = total + (mem_card * num_of); anyone? total is a float and mem_card is a double. ...

  1. #16
    Funniest man in this seat minesweeper's Avatar
    Join Date
    Mar 2002
    Posts
    801
    Is it

    Code:
    total = total + (mem_card * num_of);
    anyone?

    total is a float and mem_card is a double. So the precision obtained in mem_card might be lost when assigning this new value to total.

    Try making total a double.

  2. #17
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    i was getting similar output, can't figure out why though, sorry.

    try this to get rid of the warnings...

    Code:
                const double mem_card = 69.95;
    	const double software = 34.98;
    	const double nw_pc = 675.00;
    	const double disk_drive = 198.50;
    	double total = 0;

  3. #18
    Registered User
    Join Date
    Nov 2001
    Posts
    255
    this is the new output and we got rid of the warnings lol ty very much


    How many items would you like to buy? 3
    Which items would you like to buy(Enter one item at a time then hit enter then t
    ype in how many you want to buy)?
    software
    That is an invalid choice.
    Which items would you like to buy(Enter one item at a time then hit enter then t
    ype in how many you want to buy)?
    That is an invalid choice.
    Which items would you like to buy(Enter one item at a time then hit enter then t
    ype in how many you want to buy)?
    That is an invalid choice.
    Your total is 0
    hooch

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

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