Need help with my program!!

Well I got the code part so far im lost tho.if any of you have another code that can help me that be cool and My teacher wants the algorithm steps as well in a text file i just dont know how to set it up.

Type the Algorithm for:
A program that inputs the purchase price, then calculates the
state sales tax amount, county sales tax amount, and total sales tax amount
on the purchase. Assume the state sales tax rate is 4 percent and the county tax rate is 2 percent. Display the purchase price, state tax amount, county tax amount and total tax amount on the screen.



#include <iostream>
using namespace std;
int main()
{
float cost;
cout << "Purchase Price: ";
cin >> cost;
float stateSalesTax = cost * .1;
float price = cost + stateSalesTax;
cout << "countySalesTax" << endl;
cout << " Cost: " << cost << endl;
cout << " stateSalesTax: " << stateSalesTax << endl;
cout << "Tax amount total: " << price << endl;
system("pause");
return 0;
}
Here is the code that i did last semester, hope it helps.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//System Libraries
#include <iostream>
#include <iomanip>
using namespace std;
 
int main(int argc, char** argv) {
    //Declare Variables Here
    float Price=0;
    float SalTax= .04;
    float CounTax= .02;
    float STaxTtl;
    float CTaxTtl;
    float SCTax;
 
    cout<<"Input the Purchase price"<<endl;
    cin>>Price;
    
    //Process Input Here
    STaxTtl=Price * SalTax;
    CTaxTtl=Price * CounTax;
    SCTax=(CTaxTtl+STaxTtl);
 
    cout<<fixed<<showpoint<<setprecision(2);
    cout<<"Purchase Price $"<<Price<<endl;
    cout<<"Sales Tax $"<<STaxTtl<<endl;
    cout<<"Country Sales Tax $"<<CTaxTtl<<endl;
    cout<<"Total sale tax = $"<<SCTax<<endl;
    
    return 0;
}
Last edited on
thanks it helped alot. Is there a rule to writing an Algorithm? Can it be in my own words step by step? Do I have to explain each line or the main problem?
The best way to a program is to do it step by step, so you declare your variables then you gather your information from your user. Next you process the information (so in this case would be the mathematical part). Finally output the results. Just remember to do it all step by step.
Topic archived. No new replies allowed.