//Include the following #include <iostream> #include <string> #include <fstream> //you must include this library if you wish to do file i/o using namespace std; /********************************************************* //Following is the declaration of a order record **********************************************************/ class order_record { public: string cell_number; string item_number; double quantity; double price; int processing_plant; double tax_rate; double order_tax; double net_cost; double total_cost; }; //Prototypes for your functions: input, output, and process will go here void input(ifstream &, order_record &); void output(const order_record &); void process(order_record &); //Function Implementations will go here ///************************************************************************************* //Name: input //Precondition: State what is true before the function is called. // Example: the varialbes (formal parameters) have not been initialized //Postcondition: State what is true after the function has executed. // Example: the varaibles (formal parameters) have been initialized //Description: // Example:Get input (values of cell_number, item_number, quantity, price, processing_plant ) //from data file order record (p_record). //PURPOSE: SHOW ME THAT YOU KNOW HOW TO READ INPUT AND USE INPUT (CALL BY VALUE) & OUTPUT (CALL BY VALUE) PARAMETERS //************************************************************************************* void input(ifstream & in, order_record & p_record) // example using the call by reference mechanism in C++ -- call record is passed by reference --note & operator { in >> p_record.cell_number; //add more code to read the rest of the fields (item_number, quantity, price and processing_plant) into the //order record, p_record. } ///************************************************************************************* //Name: output //Precondition: State what is true before the function is called. //Postcondition: State what is true after the function has executed. //Description: Describe what the function does (purpose). //************************************************************************************* void output(const order_record & p_record) { //Use thee following statement to help you format you our output. These statements are called the magic formula. cout.setf(ios::showpoint); cout.precision(2); cout.setf(ios::fixed); /********************************************/ //cout << p_record.cell_number << "\t"; //add more code to print all the fields in the order record } ///************************************************************************************* //Name: process //Precondition: The state what is true before the function is called. //Postcondition: State what is true after the function has executed. //Description: Describe what the function does (purpose). //************************************************************************************* //Note: there is one 1 input/output parameter void process(order_record & p_record) { //put your code here to process/calculate the tax_rate, order_tax, net_cost, and total_cost //the p_record } //Here is your driver to test the program int main() { order_record customer_record; ifstream in; //declaring an input file stream in.open("purchase_data.txt"); if (in.fail()) { cout << "Input file did not open correctly" << endl; } else { while (!in.eof()) { input(in, customer_record); //process(customer_record); //output(customer_record); } } in.close(); return 0; }
//Include the following
#include <iostream>
#include <string>
#include <fstream> //you must include this library if you
wish to do file i/o
using namespace std;
/*********************************************************
//Following is the declaration of a order record
**********************************************************/
class order_record
{
public:
string cell_number;
string item_number;
double quantity;
double price;
int processing_plant;
double tax_rate;
double order_tax;
double net_cost;
double total_cost;
};
//Prototypes for your functions: input, output, and process will go
here
void input(ifstream &, order_record &);
void output(const order_record &);
void process(order_record &);
//Function Implementations will go here
///*************************************************************************************
//Name: input
//Precondition: State what is true before the function is
called.
// Example: the varialbes (formal parameters) have not been
initialized
//Postcondition: State what is true after the function has
executed.
// Example: the varaibles (formal parameters) have been
initialized
//Description:
// Example:Get input (values of cell_number, item_number, quantity,
price, processing_plant )
//from data file order record (p_record).
//PURPOSE: SHOW ME THAT YOU KNOW HOW TO READ INPUT AND USE INPUT (CALL BY VALUE) & OUTPUT (CALL BY VALUE) PARAMETERS
//*************************************************************************************
void input(ifstream & in, order_record & p_record) //
example using the call by reference mechanism in C++ -- call record
is passed by reference --note & operator
{
in >> p_record.cell_number;
in >> p_record.item_number;
in >> p_record.quantity;
in >> p_record.price;
in >> p_record.processing_plant;
//add more code to read the rest of the fields
(item_number, quantity, price and processing_plant) into the
//order record, p_record.
}
///*************************************************************************************
//Name: output
//Precondition: State what is true before the function is
called.
//Postcondition: State what is true after the function has
executed.
//Description: Describe what the function does (purpose).
//*************************************************************************************
void output(const order_record & p_record)
{
//Use thee following statement to help you format you
our output. These statements are called the magic formula.
cout.setf(ios::showpoint);
cout.precision(2);
cout.setf(ios::fixed);
/********************************************/
cout << p_record.cell_number <<
"\t";
cout << p_record.item_number <<
"\t";
cout << p_record.quantity << "\t";
cout << p_record.price << "\t";
cout << p_record.processing_plant <<
"\t";
cout << p_record.tax_rate << "\t";
cout << p_record.order_tax << "\t";
cout << p_record.net_cost << "\t";
cout << p_record.total_cost << endl;
//add more code to print all the fields in the order
record
}
///*************************************************************************************
//Name: process
//Precondition: The state what is true before the function is
called.
//Postcondition: State what is true after the function has
executed.
//Description: Describe what the function does (purpose).
//*************************************************************************************
//Note: there is one 1 input/output parameter
void process(order_record & p_record)
{
//put your code here to process/calculate the
tax_rate, order_tax, net_cost, and total_cost
//the p_record
if (0<=p_record.processing_plant &&
p_record.processing_plant <=50){p_record.tax_rate = .06;}
else if (50<p_record.processing_plant &&
p_record.processing_plant <=110){p_record.tax_rate = .07;}
else if (110<p_record.processing_plant &&
p_record.processing_plant <=200){p_record.tax_rate = .08;}
else if (200<p_record.processing_plant &&
p_record.processing_plant <=500){p_record.tax_rate = .09;}
else p_record.tax_rate = .11;
p_record.order_tax = p_record.quantity *
p_record.price * p_record.tax_rate;
p_record.net_cost = p_record.quantity *
p_record.price;
p_record.total_cost = p_record.net_cost +
p_record.order_tax;
}
//Here is your driver to test the program
int main()
{
order_record customer_record;
ifstream in; //declaring an input
file stream
in.open("purchase_data.txt");
if (in.fail())
{
cout << "Input file did not
open correctly" << endl;
}
else
{
while (!in.eof())
{
input(in,
customer_record);
process(customer_record);
output(customer_record);
}
}
in.close();
return 0;
}
i need help making this program the skeleton of the code is below: //Include the following #include <iostream> #...
Write a program **(IN C)** that displays all the phone numbers in a file that match the area code that the user is searching for. The program prompts the user to enter the phone number and the name of a file. The program writes the matching phone numbers to the output file. For example, Enter the file name: phone_numbers.txt Enter the area code: 813 Output: encoded words are written to file: 813_phone_numbers.txt The program reads the content of the file...
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)...
Java I: Create a Java program that will accept the price of an item and the quantity being purchased of that item. After accepting the input, calculate the amount of the purchase (based on the price and quantity), calculate the sales tax on the purchase, then output the product price, quantity, subtotal, sales tax, and the total sale based on the output format shown below. Structure your file name and class name on the following pattern: The first three letters...
Write a program in C++ that simulates a soft drink machine. The program will need several classes: DrinkItem, DrinkMachine and Receipt. For each of the classes you must create the constructors and member functions required below. You can, optionally, add additional private member functions that can be used for doing implementation work within the class. DrinkItem class The DrinkItem class will contains the following private data members: name: Drink name (type of drink – read in from a file). Type...
NEED HELP BEING SOLVED IN C++! USE ORIGINAL CODE TO ADD TO AS WELL! #include<iostream> using namespace std; int main(){ for (int i = 0; i < 7; i++) { int x,y; char opr; cin>>x>>y>>opr; switch(opr) { case '+': cout<<x<<" + "<<y<<" = "<<x+y; break; case '-': cout<<x<<" - "<<y<<" = "<<x-y; break; case '*': cout<<x<<" * "<<y<<" = "<<x*y; break; case '/': if(y == 0) cout<<x<<" / "<<y<<" = "<<"ERROR"; else cout<<x<<" / "<<y<<" = "<<x/y<<"R"<<x%y; break;...
Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses: Exception handling File Processing(text) Regular Expressions Prep Readings: Absolute Java, chapters 1 - 9 and Regular Expression in Java Project Overview: Create a Java program that allows a user to pick a cell phone and cell phone package and shows the cost. Inthis program the design is left up to the programmer however good object oriented design is required. Project Requirements Develop a text...
I need help with my homework please. I should write this program in C++ language and use Inventory.h file (header file), Inventory.cpp file (implementation file), and main.cpp file (main program). This is the program: Demonstrate the class in a driver program. Input validation, don’t accept negative values for item number, quantity, or cost. 6. Inventory Class Design an Inventory class that can hold information and calculate data for items ma retail store's inventory. The class should have the following private...
//I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...
need help on C++ Discussion: The program should utilize 3 files. player.txt – Player name data file – It has: player ID, player first name, middle initial, last name soccer.txt – Player information file – It has: player ID, goals scored, number of penalties, jersey number output file - formatted according to the example provided later in this assignment a) Define a struct to hold the information for a person storing first name, middle initial, and last name). b) Define...
Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type. Have the user specify the number of rows and the number of columns for the two dimensional array. Have the user enter the values for each row and column element in...