C++ please!
1) Create two arrays of size 10: one of antique objects and one of integers to represent the quantity of antique
2) Read from standard input the name of the file that stores the initial status of the Merchant's stock
3) Read the content of the file into the array of Antique objects and quantities. The file format is as follows:
<Antique 1 name>, <Antique 1 price>, <Antique 1 quantity> <Antique 2 name>, <Antique 2 price>, <Antique 2 quantitiy> ... <Antique 10 name>, <Antique 10 price>, <Antique 10 quantitiy>
You can assume the file will always contain 10 antiques in the above format.
file name: antiquelist.txt
inside the file:
Painting,150.10,10
Lamp,100.20,10
Rug,200.00,10
Clock,100.00,10
Sculpture,300.00,10
Photograph,200.00,10
Pottery,100.00,10
Watch,300.00,10
Wedgwood,70.00,10
Tiles,500.00,10
/* C++ program that takes the input file ,antiquelist.txt
and then read the data from the file separated by commas.Then save
the data values to the arrays . Then display the arrays data to
console window. */
//main.cpp
//include header files
#include<iostream>
#include<fstream>
#include<string>
#include<iomanip>
#include<sstream>
using namespace std;
//start of main function
int main()
{
//declare variables
const int size=10; //set size
string data;
string substr;
int index=0;
//three arrays to store names, price and
quantity
string antiqueNames[size];
double price[size];
int quantity[size];
string filename="antiquelist.txt";
//Open ifstream file object
ifstream fin;
fin.open(filename);
//check if file not exists
if(!fin)
{
//display message and exit
the program
cout<<"File not
found"<<endl;
system("pause");
return -1;
}
else
{
//Read till end of
file
while(!fin.eof() &&
index<size)
{
fin>>data;
//create
a stringstream object
stringstream
ss(data); //create string stream from the
string
getline(ss, substr, ','); //get first string delimited by
comma
antiqueNames[index]=substr;
getline(ss,
substr, ','); //get second string delimited by comma
//convert string
to float type
price[index]=atof(substr.c_str());
getline(ss,
substr, ','); //get thrid string delimited by
comma
//convert string
to integer type
quantity[index]=atoi(substr.c_str());
//increment index by 1
index++;
}
//close the fin file object
fin.close();
}
//print the antique names,price and quantity
values
cout<<left<<setw(20)<<"AntiqueNames"
<<setw(10)<<"Price"
<<setw(10)<<"Quantity"<<endl;
cout<<left<<setw(20)<<"==============="
<<setw(10)<<"====="
<<setw(10)<<"======="<<endl;
for(index=0;index<size;index++)
{
cout<<left<<setw(20)<<antiqueNames[index]
<<setw(10)<<price[index]
<<setw(10)<<quantity[index]<<endl;
}
system("pause");
return 0;
}
-------------------------------------------------------------------------------------------------------------------
Input file : antiquelist.txt
Painting,150.10,10
Lamp,100.20,10
Rug,200.00,10
Clock,100.00,10
Sculpture,300.00,10
Photograph,200.00,10
Pottery,100.00,10
Watch,300.00,10
Wedgwood,70.00,10
Tiles,500.00,10
-------------------------------------------------------------------------------------------------------------------
sample output:

C++ please! 1) Create two arrays of size 10: one of antique objects and one of...
Antique Class Each Antique object being sold by a Merchant and will have the following attributes: name (string) price (float) And will have the following member functions: mutators (setName, setPrice) accessors (getName, getPrice) default constructor that sets name to "" (blank string) and price to 0 when a new Antique object is created a function toString that returns a string with the antique information in the following format <Antique.name>: $<price.2digits> Merchant Class A Merchant class will be able to hold...
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...
C++ please! OVERVIEW This homework builds on HW4. 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 for the Antique and Merchant classes, as we simplified their functionality for this homework. Also, you...
Create 4 arrays: a 1-D array to store the students’ id, 1-D array to store the students’ names, a parallel 2-D array to store the test scores, and a parallel 1-D array to store letter grades. Read data into the 3 arrays from the file data121.txt. If the file is not found, the program needs to terminate with this error, “Data file not found.” Calculate and store a letter grade into a 1-D array based on the total score, sum...
Create 4 arrays: a 1-D array to store the students’ id, 1-D array to store the students’ names, a parallel 2-D array to store the test scores, and a parallel 1-D array to store letter grades. Read data into the 3 arrays from the file data121.txt. If the file is not found, the program needs to terminate with this error, “Data file not found.” Calculate and store a letter grade into a 1-D array based on the total score,...
Serve the user in two phases: In C++ Phase A: (1) Read all input records one by one into arrays in main memory. (2) Display all the records on the screen in the order they are read from the input data file. (3) Do a Selection Sort (must be implemented as a function) to sort the records in ascending order on STUDENT_ID and display all the full records correctly in the correct order after sorting. Phase B: (1) Then, the...
java: 1d arrays PLEASE NEED HELp THANK YOU!!! One dimensional (1D) array 1. Create an array of 1000 integers. Name the array: x 2. Assign 95 to the ninth element, 25 to the twentieth element of array x. 3. Assign the sum of the ninth and the twentieth element to the sixtieth element of array x. 4. Display the sixtieth element of the array. 5. Use the for statement to generate all indexes to read and display all elements in...
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)...
design a C program to control the stock of books of a small bookstore. Part 1: for the cout, it should be printf(" "); should write like that When a client orders a book, the system should check if the bookstore has the book in stock. If the bookstore keeps the title and there is enough stock for the order, the system should inform the price per copy to the client, as well as the total price of the purchase....
Mountain Paths (Part 1) in C++ Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e. parallel arrays … called multiple arrays in the zyBook) Transform data Read from files Write to files structs Code Requirements Start with this code: mtnpathstart.zip Do not modify the function signatures provided. Do not #include or #include Program Flow Read the data into a 2D array Find min and max elevation to correspond to darkest and brightest color, respectively Compute the shade of...