Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

[HELP] Something wrong in my code( works for first part of problem)

Trying to get this program to work for my CSI class but keep getting an error. The task was to add up a collection amount of pennies(135), nickels(321), dimes(573), Quaters(857).

I need to code it to display the total amount $(float)
then show 24% going to david (d)
then show 76% going to office (d)

from my understand i labeled my variables correctly

works fine for adding total $ amount but not when i try to do the 24% and 76% of total. Any help would be appricated as i am new to using c++


Code
#include <cstdlib>
#include <iostream>

using namespace std;

//Calculates the daily dollar amount of Quarters, Dimes, Nickels, and Pennies collected and gives 25% to David and 76% to the office//
main()
{
      int num1=135, num2=321, num3=573, num4=857;
      float p=0.001, n=0.005, d=0.10, q=0.25, sum, parking=.75, david=.25;
    cout << "Enter the amount of pennies\n";
    cin >> num1;

    cout << "Enter the amount of nickels\n";
    cin >> num2;

    cout << "Enter the amount of dimes\n";
    cin >> num3;
    
    cout << "Enter the amount of quaters\n";
    cin >> num4;

    sum=p*num1 + n*num2 + d*num3 + q*num4; //"Total Amount Collected"//

    cout << "The answer is \n\n" << sum;

    cin >> parking
        parking=p*num1 + n*num2 + d*num3 + q*num4/.75

    cout << "The answer is \n\n" << parking;

    cin >> david
      
      david=p*num1 + n*num2 + d*num3 + q*num4/.25
    cout << "The answer is \n\n" << david;


}

i was able to get the code to work. now closed


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by imrankhanDec 28, 2013 06:22 PM 19 588 Dec 28, 2013 06:22 PM
Last Post: Сlassy
[Python] by ๖ۣۜAlexanderSep 11, 2013 11:09 AM 11 234 Sep 11, 2013 11:09 AM
Last Post: kieranlav
[Shell] by jgadianeAug 11, 2012 02:48 AM 9 231 Aug 11, 2012 02:48 AM
Last Post: Jаck