Hello, here is the completed code you wanted. Every important statement is explained using comments. Please check and let me know if you have any doubts. Thanks.
I have completed the program in C++ , because there is no language specified in the question. If you want it in any high level language please comment.
CODE
#include<fstream>
#include<iostream>
#include<iomanip>
using namespace std;
//tax declared as global
double tax = 0.08875;
//function to print program heading and intro
void printHeading()
{
//printing heading
cout<<"\t\t\tXYZ Book Store Sales
Register";
cout<<"\n_______________________________________________________________________\n";
//printing intro
cout<<"\nThis program calculates your total bill
and generates a receipt for you. \nPlease enter 'x' to exit the
program\n";
}
//function to calculates total with sales tax
double calcTotal(double amt)
{
//calculating total amount
amt = amt + (amt * tax);
//returns total amount
return amt;
}
//function to read input print output to screen and write to
file
void processInput()
{
//variables
string name;
double price, total = 0;
ofstream outfile;
//opening file
outfile.open("Receipt.txt");
outfile<<"\nXYZ Book Store Receipt";
outfile<<"\n_______________________________________________________________________\n";
while(true)
{
//clearing buffer
fflush(stdin);
//prompt for name
cout<<"\nPlease enter the
name of the book: ";
getline(cin, name);
//if name is x
if(name == "x")
break;
//prompt for price
cout<<"\nPlease enter the
price: ";
cin>>price;
//calculating total
total = total + price;
//writing name and price to
file
outfile<<"\n"<<name<<"\t$"<<price;
}
//printing total amount
cout<<"\nAmount: $"<<total;
//printing sales tax
cout<<"\nSales Tax:
"<<(tax*100)<<"\%";
//writing total amount
outfile<<"\nAmount: $"<<total;
//writing sales tax
outfile<<"\nSales Tax:
"<<(tax*100)<<"\%";
//calling calcTotal
total = calcTotal(total);
//printing and writing total amount with tax
cout<<"\nTotal Amount Due:
"<<fixed<<setprecision(2)<<total;
outfile<<"\nTotal Amount Due:
"<<fixed<<setprecision(2)<<total;
}
//main function
int main()
{
//calling printHeading
printHeading();
//calling processInput
processInput();
}
OUTPUT
CODE SCREEN SHOT
CSC 126 Arrays, Functions, & File 'O Part I Your program should prompt the user to...
I need this python program to access an excel file, books inventory file. The file called (bkstr_inv.xlsx), and I need to add another option [search books], option to allow a customer to search the books inventory, please. CODE ''' Shows the menu with options and gets the user selection. ''' def GetOptionFromUser(): print("******************BookStore**************************") print("1. Add Books") print("2. View Books") print("3. Add To Cart") print("4. View Receipt") print("5. Buy Books") print("6. Clear Cart") print("7. Exit") print("*****************************************************") option = int(input("Select your option:...
Programming Assignment 1 Structures, arrays of structures, functions, header files, multiple code files Program description: Read and process a file containing customer purchase data for books. The books available for purchase will be read from a separate data file. Process the customer sales and produce a report of the sales and the remaining book inventory. You are to read a data file (customerList.txt, provided) containing customer book purchasing data. Create a structure to contain the information. The structure will contain...
1.b) Create a Java application Lab3Part1b. Make sure you create a NEW project with the specific name just given. You need to make sure the projects you create and submit have the correct names and the name of the file and name of the class are the same. The names are case sensitive. In this new project, set up your program to read in the data from the file SciFiDataBMTClean.txt using a Scanner. {file/Scanner setup 2 points} Declare the variables...
Please add code for program. movies.txt file. LAB 14-2 Plan and Create In this lab, you will plan and create an algorithm for Cheryl Liu, the owner of a candy shop named Sweets-4-You. The problem specification is shown in Figure 14-15. Problem specification Cheryl Liu is the owner of a candy shop named Sweets-4-You. She wants a program that displays the following menu: Menu Options 1 Add Records 2 Display Total Sales 3 Exit If Cheryl selects option 1, the...
In C++ Programming Write a program in Restaurant.cpp to help a local restaurant automate its breakfast billing system. The program should do the following: Show the customer the different breakfast items offered by the restaurant. Allow the customer to select more than one item from the menu. Calculate and print the bill. Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item): Name Price Egg (cooked to order)...
This interactive program focuses on if/else statements, Scanner, and returning values. Turn in a file named Budgeter.java. To use a Scanner for console input, you must import java.util.*; in your code. This program prompts a person for income and expense amounts, then calculates their net monthly income. Below are two example logs of execution from the program. This program’s behavior is dependent on the user input (user input is bold and underlined below to make it stand out and differentiate...
IN c++ i post this question 5 times. hope this time somebody answer.. 16.5 Homework 5 OVERVIEW This homework builds on Hw4(given in bottom) We will modify the classes to do a few new things We will add copy constructors to the Antique and Merchant classes. We will overload the == operator for Antique and Merchant classes. We will overload the + operator for the antique class. We will add a new class the "MerchantGuild." Please use the provided templates...