Advertisement
PRDarkSide

Ch9_Ex1

Jan 26th, 2022
1,208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.61 KB | None | 0 0
  1. // CH9_EX1.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include <iostream>
  5. #include <string>
  6. #include <iomanip>
  7.  
  8. using namespace std;
  9.  
  10. struct computer
  11. {
  12.     string manufacturer;
  13.     string modelType;
  14.     string processorType;
  15.  
  16.     int ram;
  17.     int hardDriveSize;
  18.     int yearBuilt;
  19.  
  20.     float price;
  21. };
  22.  
  23. int main()
  24. {
  25.     computer myComputer;
  26.  
  27.     cout << fixed << showpoint << setprecision(2);
  28.  
  29.     cout << "Enter the name of the manufacturer: ";
  30.     getline(cin, myComputer.manufacturer);
  31.     cout << endl;
  32.  
  33.     cout << "Enter the model of the computer: ";
  34.     getline(cin, myComputer.modelType);
  35.     cout << endl;
  36.  
  37.     cout << "Enter processor type: ";
  38.     getline(cin, myComputer.processorType);
  39.     cout << endl;
  40.  
  41.     cout << "Enter the size of RAM (in GB): ";
  42.     cin >> myComputer.ram;
  43.     cout << endl;
  44.  
  45.     cout << "Enter the size of hard drive (in GB): ";
  46.     cin >> myComputer.hardDriveSize;
  47.     cout << endl;
  48.  
  49.     cout << "Enter the year the computer was built: ";
  50.     cin >> myComputer.yearBuilt;
  51.     cout << endl;
  52.  
  53.     cout << "Enter the price: ";
  54.     cin >> myComputer.price;
  55.     cout << endl;
  56.  
  57.     cout << "Manufacturer: " << myComputer.manufacturer << endl;
  58.     cout << "Model: " << myComputer.modelType << endl;
  59.     cout << "Processor: " << myComputer.processorType << endl;
  60.     cout << "Ram: " << myComputer.ram << endl;
  61.     cout << "Hard Drive Size: " << myComputer.hardDriveSize << endl;
  62.     cout << "Year Built: " << myComputer.yearBuilt << endl;
  63.     cout << "Price: $" << myComputer.price << endl;
  64.  
  65.     return 0;
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement