Does anyone know how to write a program in Python?

SoccerBoss
Category:
Programming
Price: $10 USD

Question description

COMPROG.pdf 

Someone else wrote this is C++ but my teacher said that I did not use the Python code to write the program! I need the source code re-written using the Python program language. 

CSC 122-Section # - Program #1

By RyleyO

Due: February 2nd, 2015

The purpose of the program is to provide the price, subtotal, sales tax, and total of various items for a customer.

#include <iostream> 

using namespace std; 

int main(void) 

//declarations 

double item1 = 0; 

double item2 = 0; 

double item3 = 0; 

double item4 = 0; 

double item5 = 0; 

double subtotal = 0; 

double total = 0; 

double tax = 0; 

//Enter Items 

cout << "Please enter the price of item 1"; 

cin >> item1; 

cout << "Please enter the price of item 2"; 

cin >> item2; 

cout << "Please enter the price of item 3"; 

cin >> item3; 

cout << "Please enter the price of item 4"; 

cin >> item4; 

cout << "Please enter the price of item 5"; 

cin >> item5; 

//Compute subtotal 

subtotal = (item1 + item2 + item3 + item4 + item5 + item6+); 

//Compute amount of tax 

tax = subtotal * (0.07); 

//Compute total 

total = subtotal + tax; 

#include "stdafx.h" 

#include <iostream> 

using namespace std; 

int main() 

// here 5 diff. var. hold 5 diff. prices 

int item1=15.89; 

int item2=0.47; 

int item3=6.95; 

int item4=11.33; 

int item5=8.71; 

// Calculate the subtotal. 

int subtotal = item1 + item2 + item3 + item4 + item5; 

// Calculate the tax. 

double tax = subtotal *.07 ; // tax to be taken as double/float type because tax is in decimals 

// Calculate total by adding subtotal and tax 

double total = subtotal tax; 

// Display the subtotal. 

cout<< "The meal charge $" << subtotal <<endl; 

// Display the tax charge. 

cout<<"The tax charge $" << tax << endl; 

// Display the total. 

cout<<"The total amount spent $" << total << endl; 

system ("pause"); 

return 0; 

//Display subtotal, total, and amount of tax 

cout < " The subtotal of the sale is: " << subtotal << endl; 

cout < " The amount of sales tax is: " << tax << endl; 

cout < " The total of the sale is: " << total << endl; 

return 0; 


Tutor Answer

(Top Tutor) Daniel C.
(997)
School: University of Virginia
PREMIUM TUTOR
Studypool has helped 1,244,100 students
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1821 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors