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

1. Debug and Rewrite the following program using cin >> 2. Code the program and

ID: 3640025 • Letter: 1

Question

1. Debug and Rewrite the following program using cin >>
2. Code the program and ensure that the output will have all number displayed with 2 decimals places




include <iostreaming.h>
int main ( )
/* Welcome to <YOUR NAME > Market

//Declaration Statement
int sales1, Sales2, tax rate, taxes, subtotal, bill ;
// Assignment Statement
price1 = 4.50;
price2 = 10.90 ;
//Processing
subtotal = price1 + price2 ;
taxrate = .0875 ;
taxes = subtotal * taxrate
bill = subtotal + taxes ;

// Output
cout <<“The Subtotal is $ ” << subtotal << endl
cout “The Tax is $ ” <<taxes << endl ;
cout <<“Your Bill is $ ” << bill << endl;
return 0;
}

Explanation / Answer

Working Code:


#include<iostream>
#include <iomanip>
using namespace std;
int main ( )
{
/* Welcome to <YOUR NAME > Market*/

//Declaration Statement
double price1, price2, taxrate, taxes, subtotal, bill ;
// Assignment Statement
cout<<"Enter price1:";
cin>>price1;
cout<<"Enter price2:";
cin>>price2;
//Processing
subtotal = price1 + price2 ;
taxrate = .0875 ;
taxes = subtotal * taxrate;
bill = subtotal + taxes ;

// Output
cout <<"The Subtotal is $ " <<setprecision(2)<< fixed<< subtotal << endl;
cout <<"The Tax is $ "<<setprecision(2) << fixed<<taxes << endl ;
cout <<"Your Bill is $ " <<setprecision(2)<< fixed<< bill << endl;
return 0;
}