1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
muminat
2 years ago
5

Create 2 methods of your choice.

Computers and Technology
1 answer:
lyudmila [28]2 years ago
5 0
I can’t find how to do this
You might be interested in
Write a program that reads raw data from a file that contains an inventory of items. The items should be sorted by name, and the
Anika [276]

Answer:

//C++ code

#include<iostream>

#include<fstream>

#include<iomanip>

using namespace std;

/*===============================================*/

// a structure called prod

struct prod

{

string name;// – a string, assumed to have no spaces

double price; // –adollaramount

int inStock; // – the number of items currently in stock.

};

//Fucntion Prototypes

void readInventory(prod products[], int& size);

/*===============================================*/

/*returns: a dollar amount, the total value of the inventory*/

double totalValue(prod products[], int size);

/*===============================================*/

// Sorts the given array by name

void sort(prod products[], int size);

/*===============================================*/

/*a report to a file called “report.txt”.

When the file fails to open, print

“Unable to open output file.” and end.*/

void writeReport(prod products[], int size);

/*===============================================*/

//Function definitions

/*===============================================*/

void writeReport(prod products[], int size)

{

ofstream outfile("report.txt");

outfile << fixed << setprecision(2);

if (!outfile)

{

cout << "Unable to open output file.\n";

return;

}

outfile << "+------------------------------+\n | Current Inventory |\n\

\n+------------------------------+\nNAME PRICE #\n\

\n-------------------- ------- ---\n";

for (int i = 0; i < size; i++)

{

outfile << products[i].name << " " << products[i].price << " " << products[i].inStock << endl;

}

outfile << "+------------------------------+\n";

outfile << "Number of products: " << size << endl;

outfile << "Inventory total value: " << totalValue(products, size) << endl;

cout << "Report written to file\n";

//close the output stream

outfile.close();

}

/*===============================================*/

void sort(prod products[], int size)

{

for (int i = 0; i < size; i++)

{

for (int j = i+1; j < size; j++)

{

if (products[i].name > products[j].name)

{

//swapping

prod temp = products[i];

products[i] = products[j];

products[j] = temp;

}

}

}

}

/*===============================================*/

double totalValue(prod products[], int size)

{

double total = 0;

for (int i = 0; i < size; i++)

{

total += products[i].inStock * products[i].price;

}

return total;

}

/*===============================================*/

void readInventory(prod products[], int& size)

{

// Open a file called “inventory.txt”

//and read the data from the file into the partial array

//.If the file fails to open,

//print “Unable to open input file”

//and set the number of products to 0.

size = 0;

ifstream inFile("inventory.txt");

if (!inFile)

{

cout << "Unable to open input file.\n";

return;

}

string name;

double price;

int qunatity;

while (inFile >> price >>qunatity >>name)

{

if (price != -1 && qunatity != -1 && name != "endofdata")

{

products[size].name = name;

products[size].inStock = qunatity;

products[size].price = price;

size++;

}

}

cout << "inventory read\n";

//close the stream

inFile.close();

}

/*===============================================*/

int main()

{

//declares a partial array of products

prod products[100];

int size;

// invokes readInventory()

readInventory(products, size);

// invokes sort()

sort(products, size);

// invokes writeReport()

writeReport(products, size);

// ends with the standard system pause.

system("pause");

return 0;

}

please see attachment for inventory text and output.

4 0
3 years ago
What are some examples of productions categorized as non-broadcast productions?
leonid [27]

Answer:

Non-broadcast media incorporates

  • Recorded television
  • Radio
  • Podcasts
  • Internet
  • Streaming services.

Explanation:

Non-broadcast media is a phrase used to represent audio and visual communications that can be obtained at any moment. Non-broadcast media is the knowledge that can be switched on and off, suspended, rewound, and fast-forwarded at certain times.

Examples of non-broadcast productions

Non-broadcast media incorporates

  • Recorded television
  • Radio
  • Podcasts
  • Internet
  • Streaming services.

To learn more about broadcast productions refer:

  • https://brainly.in/question/17335292
  • https://brainly.in/question/44811105

4 0
3 years ago
I am buying a BluRay drive access time is 180ms and the other is 210ms(BD-ROM) whats does access time mean
kkurt [141]
It means how fast it can read the disk so if you want faster data transfer you would go for blurry if you really don't care go for the other one
6 0
2 years ago
What did basic elements of music look like in the Twentieth Century period?
Alexandra [31]

Answer:

I just want my 5 point lol sorry hope you get your answer

Explanation:

get terraria

5 0
3 years ago
Why shouldn't a server use a glass to scoop ice?
natali 33 [55]
A server shouldn't use a glass to scoop ice as the glass may break. This is due to the potential temperature difference between the glass (which may be room temperature or hotter if it is taken from a dishwasher), and the cold ice. Any existent hairline fractures in the glass may then expand and crack, whereby the smashed pieces of glass could then land in the client's food, table or lap, potentially causing injury to the person. 
7 0
3 years ago
Read 2 more answers
Other questions:
  • A compound document contains _______ from different applications.
    12·2 answers
  • For which task is the WordArt gallery most useful?
    15·2 answers
  • The file type ____ identifies a word 2013 document.
    11·1 answer
  • Narrowband Satellite Communications supports ______________ data rates for both mobile and fixed users by providing access on a
    8·1 answer
  • Which would you trade on a stock exchange? A: Shares B: Bonds C: Annuities
    6·2 answers
  • Define the function max2 that takes two integers as arguments and returns the largest of them. Then define the function max_list t
    11·1 answer
  • Write a calculate_sq_inches_of_good_pizza function that accepts the diameter of a pizza and returns the area of the pizza minus
    7·1 answer
  • Add me on blizzard none of my friends play ow<br> NADERJABER#2530
    8·1 answer
  • I'm getting pretty desperate plz help me, I'll give brainiest, and ill make a free question worth 100 points this is for coding
    10·1 answer
  • In which number system do the digital computer work​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!