Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please write a c++ code for my pseudo code. I am take a class that is teaching m

ID: 3879789 • Letter: P

Question

Please write a c++ code for my pseudo code. I am take a class that is teaching me flow charts and pseudocode and I would like to see the actual code so that I can start preparing myself for next semester’s classes.

Here is the pseudo cod:

// Global constants for tax calculations

Constant Real COUNTY_TAX_RATE = .02

Constant Real STATE_TAX_RATE = .04

// main module

Module main()

// Local variables

Declare Real monthSales, countyTax, stateTax

// Get month sales

Call getSales(monthSales)

// Calculate county tax

Call setCounty(monthSales, countyTax)

// Calculate state tax

Call setState(monthSales, stateTax)

// Display tax amount

Call showTaxes(monthSales, countyTax, stateTax)

End Module

// The getSales module gets count of month sales and stores it

// in the inputSales reference variable.

Module getSales (Real Ref inputSales)

      Display “Enter monthly sales: ”

      Input inputSales

End Module

// The setCounty module sets the county tax and stores it

// in the countyTax reference variable.

Module setCounty(Real monthSales, Ref countyTax)

      Set countyTax = monthSales * COUNTY_TAX_RATE

End Module

// The setState module sets the state tax and stores it

// in the stateTax reference variable.

Module setState(Real monthSales, Ref stateTax)

      Set stateTax = monthSales * STATE_TAX_RATE

End Module

// The showTaxes module accepts monthSales, countyTax, stateTax

// as arguments and displays the resulting data

Module showTaxes(monthSales, countyTax, stateTax)

Declare Real totalTaxes

Set totalTaxes = countyTax + stateTax

Display "Amount of Monthly Sales: $", monthSales

Display "Amount of County Sales Tax: $", countyTax

Display "Amount of State Sales Tax: $", stateTax

Display "Total Taxes: $", totalTaxes

End Module

Thanks

Explanation / Answer

Hello, Following is the C++ code for the psedo-code given by you:-

#include<iostream>
using namespace std;

float COUNTY_TAX_RATE=0.02;
float STATE_TAX_RATE=0.04;

float getSales()
{
    float x;
    cout<<"Enter Monthly Sales : ";
    cin>>x;
    return x;
}

float setCounty(float monthSales)
{
    return monthSales*COUNTY_TAX_RATE;
}

float setState(float monthSales)
{
    return monthSales*STATE_TAX_RATE;
}

void showTaxes(float monthSales, float countyTax, float stateTax)
{
    float TotalTax = countyTax + stateTax;
    cout<<"Amount of Monthly Sales : "<<monthSales<<"$"<<endl;
    cout<<"Amount of County Sales : "<<countyTax<<"$"<<endl;
    cout<<"Amount of State Sales : "<<stateTax<<"$"<<endl;
    cout<<"Total Taxes : "<<TotalTax<<"$"<<endl;
}

int main()
{
    float monthSales, countyTax, stateTax;

    monthSales = getSales();

    countyTax = setCounty(monthSales);

    stateTax = setState(monthSales);

    showTaxes(monthSales, countyTax, stateTax);

    return 0;
}