Question

In: Computer Science

Using Dev-C++ write a program that allows a small business owner to input, in parallel arrays,...

Using Dev-C++ write a program that allows a small business owner to input, in parallel arrays, the type of item, its cost, and the number in stock. The program should output this information in the form of a table. The output will look something like below. Also, assume for a finite number of item name of 3
Item Name Cost Number in Stock
Widget 25.00 4

... ... ...

Wombet 47.50 9

Prelude to Programming (6th edition)

Solutions

Expert Solution

Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================

#include<iostream>
#include<iomanip>
#include<string>


using namespace std;

int main(){
  
   string names[3];
   double prices[3];
   int quantities[3];
  
   for(int i=0; i<3; i++){
       cout<<"Enter Details for Item #" << i+1<<endl;
       cout<<"Enter item name: "; getline(cin,names[i],'\n');
       cout<<"Enter item price: "; cin >> prices[i];
       cout<<"Enter quantity: "; cin >> quantities[i];
       cin.ignore(256,'\n');
       cout<<endl;
      
   }
  
   cout<<left<<setw(15)<<"Item Name";
   cout<<right<<setw(10)<<"Cost";
   cout<<right<<setw(20)<<"Number in Stock";
   cout<<endl;
  
       for(int i=0; i<3; i++){
          
           cout<<left<<setw(15)<<names[i];
           cout<<right<<setprecision(2)<<fixed<<showpoint<<setw(10)<<prices[i];
           cout<<right<<setw(10)<<quantities[i];
           cout<<endl;
          
       }
  


   return 0;
}
================================================================


Related Solutions

Write a C++ program to do the following USING ARRAYS 1) input 15 integers (input validation...
Write a C++ program to do the following USING ARRAYS 1) input 15 integers (input validation , all numbers must be between 0 and 100) 2) find the largest number 3) Find the Smallest Number 4) Find the Sum of all numbers in the Array Display: as per the user's section (menu using switch or if else ) Largest Number Smallest Number Sum of all numbers the original Array DO NOT USE METHODS OR FUNCTIONS Submit: Source code (C++) output...
A local instructor wants you to write a c++ program using arrays to calculate the average...
A local instructor wants you to write a c++ program using arrays to calculate the average score made on exams by her students. For simplicity, she always has only 12 students in each course she teaches. She teaches multiple subjects so she would like to enter the name of the exam. She wants the program to also determine the highest and lowest scores and the number of students who passed and failed the exam. A score of 60 or above...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute an approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is:...
C++ DO not use arrays to write this program. Write a program that repeatedly generates three...
C++ DO not use arrays to write this program. Write a program that repeatedly generates three random integers in the range [1, 100] and continues as follows: If the right-most digit of all the three integers is equal, the program displays them in ascending order on the screen and continues. If the generated integers have different right-most digits, they are not displayed and the program continues. The program terminates once the right-most digits of all the three random numbers are...
Write a program the declares and uses two parallel arrays. One array for storing the names...
Write a program the declares and uses two parallel arrays. One array for storing the names of countries and a second array for storing the populations of those countries. As you can see per the following the Country name and it's corresponding Population are stored at the same element index in each array. China 1367960000 India 1262670000 United States 319111000 Indonesia 252164800 Brazil 203462000 Pakistan 188172000 Nigeria 178517000 Bangladesh 157339000 Russia 146149200 Japan 127090000 In the main method write a...
Write a program the declares and uses two parallel arrays. One array for storing the names...
Write a program the declares and uses two parallel arrays. One array for storing the names of countries and a second array for storing the populations of those countries. As you can see per the following the Country name and it's corresponding Population are stored at the same element index in each array. China 1367960000 India 1262670000 United States 319111000 Indonesia 252164800 Brazil 203462000 Pakistan 188172000 Nigeria 178517000 Bangladesh 157339000 Russia 146149200 Japan 127090000 In the main method write a...
Write C program Multidimensional Arrays Design a program which uses two two-dimensional arrays as follows: an...
Write C program Multidimensional Arrays Design a program which uses two two-dimensional arrays as follows: an array which can store up to 50 student names where a name is up to 25 characters long an array which can store marks for 5 courses for up to 50 students The program should first obtain student names and their corresponding marks for a requested number of students from the user. Please note that the program should reject any number of students that...
Write a C++ Program Write a program that prompts the user to input a string. The...
Write a C++ Program Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must insert the following comments at the beginning...
Q20. Using C++ style string to write a program that reads a sentence as input and...
Q20. Using C++ style string to write a program that reads a sentence as input and converts each word of the sentence following the rule below: For every word in the sentence, the first letter is relocated the end of the word. Then append the string “KPU” to the word. More requirements: All letters in the output should be uppercase. More assumptions: The input sentence contains no non-alphabetic letters Sample Run: Please enter the original sentence: i LOVE to program...
Q20. Using C++ style string to write a program that reads a sentence as input and...
Q20. Using C++ style string to write a program that reads a sentence as input and converts each word of the sentence following the rule below: For every word in the sentence, the first letter is relocated the end of the word. Then append the string “KPU” to the word. More requirements: All letters in the output should be uppercase. More assumptions: The input sentence contains no non-alphabetic letters Sample Run: Please enter the original sentence: i LOVE to program...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT