Problem: A local company, Molding Supreme, uses produces molds to cast various shapes. However, the molds become scratched after many uses and need to be replaced which costs a lot of money. Therefore the company has been researching various formulations mold materials and heat treatments to produce a material that is not too expensive and that resists scratching. You are asked to develop a program that will help the researchers analyze the data. The researchers use multiple formulations and apply various heat treatments to these formulations. The researchers need a program to determine the highest and second highest hardness for each formulation.
Your program should ask the user to enter the formulation name. Next your program should ask the user how many heat treatments were used for that formulation. The number of heat treatments must be at least 3. The user should then be prompted to enter a hardness value for each of the treatments of that formulation and output the highest and second highest hardness for that formulation.
Your code should use a single string object to store the name of the formulation, a while loop to check that the number of heat treatments is at least 3, a for loop to enter the hardness for each heat treatment and determine the highest hardness and second highest hardness values, a while loop to ensure that the hardness is greater than 0 and less than or equal to 11 and a do-while loop to repeat for additional formulations.
I get errors like this declaration has no storage class or type specifier and expected a declaration.
do
{
cout << "What is the name of the formulation?" << endl;
cin >> form;
cout << "How many heat treatments were used for formulation " << form << "." << endl;
cin >> numTreat;
while (numTreat < 3)
{
cout << "The value you have entered is invalid, please enter a vlaue greater than or equal to 3" << endl;
cin >> numTreat;
}
for (int i = 1; i <= numTreat; i++)
{
cout << "Enter the hardness for treatment " << i << "of formulation " << form << ".";
cin >> hard;
while (hard <= 0 || hard > 11) {
cout << "The value you have entered is invalid, please enter a value greater than 0 and less than or equal to 11" << endl;
cin >> hard;
}
cout << "The hardness value is" << hard << "." << endl;
if (hard > highest) {
secHigh = highest;
highest = hard;
}
}
cout << "The highest hardness for " << form << "is" << highest << "." << endl;
cout << "The second highest for " << form << "is" << secHigh << "." << endl;
cout << "Are there any other formulations? Enter y for yes and n for no. " endl;
cin >> yes_no;
}
while (yes_no == 'y');