Server IP : 172.16.15.8 / Your IP : 3.139.108.48 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/acyurksaitis/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
Script started on Wed 06 Feb 2008 08:10:01 PM EST [acyurksaitis@zeus acyurksaitis]$ pico homework1.cppexit[Kpico homework1.cpp.cpp[K2.cpp [1;1H[J[7m UW PICO(tm) 4.2 New Buffer [m[48;1H[K[49;1H[K[48;1H[7m^[m[7mG[m Get Help [7m^[m[7mO[m WriteOut [7m^[m[7mR[m Read File [7m^[m[7mY[m Prev Pg [7m^[m[7mK[m Cut Text [7m^[m[7mC[m Cur Pos [K[49;1H[7m^[m[7mX[m Exit [7m^[m[7mJ[m Justify [7m^[m[7mW[m Where is [7m^[m[7mV[m Next Pg [7m^[m[7mU[m UnCut Text [7m^[m[7mT[m To Spell [K[3;1H[47;1H[K[47;93H[7m[ Reading file ][m[47;1H[K[47;93H[7m[ Read 76 lines ][m[1;94H[7mFile: homework2.cpp[m[3;1H// CS212 HW #2: homework2.cpp[4;1H//[5;1H// Due: February 13, 2008[6;1H//[7;1H// Author: Amy Yurksaitis[8;1H//[9;1H// Instructor: Dr. Wang[10;1H//[11;1H// Goal: To write a program that allows the user to input student[12;1H// data such as; name, age, and test scores. Then the program[13;1H// will output to the screen that information plus the[14;1H// students average, the class average,[15;1H// and the average age of the class[16;1H//[17;1H// Compile: g++ homework2.cpp -o homework2.out[18;1H// Run: ./homework2.out[19;1H/////////////////////////////////////////////////////////////////////////////[22;1H#include<iostream>[23;1H#include<iomanip>[25;1Husing namespace std;[27;1Hstruct Student[28;1H{ string name;[29;9Hint test1, test2, final;[30;9Hint age;[31;9Hfloat avg;[32;1H};[35;1Hint main()[36;1H{[37;9HStudent someone;[38;9Hchar dummy;[39;9Hfloat class_total = 0;[40;9Hfloat class_size = 0;[41;9Hfloat class_avg;[42;9Hfloat avg_age = 0;[43;9Hfloat total_age;[45;9Hcout << "Input the name: ";[46;9Hgetline (cin, someone.name) ;[3;1H[4;1H[5;1H[6;1H[7;1H[8;1H[9;1H[10;1H[11;1H[12;1H[13;1H[14;1H[15;1H[16;1H[17;1H[18;1H[19;1H[20;1H[21;1H[22;1H[23;1H[24;1H[25;1H[26;1H[27;1H[28;1H[47;1H[K[29;1H[30;1H[31;1H[32;1H[33;1H[34;1H[35;1H[36;1H[37;1H[38;1H[39;1H[40;1H[41;1H[42;1H[43;1H[44;1H[45;1H[46;1H[3;1Husing namespace std;[K[4;1H [5;1Hstruct Student[K[6;1H{ string name;[7;1H int test1, test2, final;[8;1H int age;[9;1H float avg;[K[10;1H};[11;1H[K[12;1H[K[13;1Hint main()[K[14;1H{[K[15;1H Student someone;[K[16;1H char dummy;[17;1H float class_total = 0;[K[18;1H float class_size = 0; [19;1H float class_avg;[K[20;9Hfloat avg_age = 0;[21;9Hfloat total_age;[22;1H[K[23;1H cout << "Input the name: ";[24;9Hgetline (cin, someone.name) ;[25;1H[K[26;9Hwhile(cin)[27;1H {[K[28;1H cout << "Enter student's age: ";[29;9H cin >> someone.age ;[30;9H cout << "Three exam scores: ";[31;9H cin >> someone.test1 >> someone.test2 >> someone.final;[32;1H [33;17Hclass_size ++;[34;17Hsomeone.avg = (someone.test1 + someone.test2 + someone.final)/4.0 ;[35;1H class_total += someone.avg;[36;1H avg_age += someone.age;[37;9H[K[38;9H cout << "Name: " << someone.name << endl;[39;9H cout << "Age: " << someone.age << endl;[40;9H cout << "Test 1: " << someone.test1 << endl;[41;9H cout <<"Test 2: " << someone.test2 <<endl;[42;9H cout <<"Final: " << someone.final <<endl;[43;9H cout << "Student average: " << fixed << setprecision(1) << someone.avg << endl;[44;17Hcin.get(dummy);[45;9H cout <<"Input the name: ";[46;9H getline(cin, someone.name);[25;1H[26;1H[27;1H[28;1H[29;1H[30;1H[31;1H[32;1H[33;1H[34;1H[35;1H[36;1H[37;1H[38;1H[39;1H[40;1H[41;1H[42;1H[43;1H[44;1H[45;1H[46;1H[3;1H[K[4;9Hwhile(cin)[5;1H {[K[6;1H cout << "Enter student's age: ";[7;9H cin >> someone.age ;[8;9H cout << "Three exam scores: ";[9;9H cin >> someone.test1 >> someone.test2 >> someone.final;[10;1H [11;17Hclass_size ++;[12;17Hsomeone.avg = (someone.test1 + someone.test2 + someone.final)/4.0 ;[13;1H class_total += someone.avg;[14;1H avg_age += someone.age;[15;9H[K[16;9H cout << "Name: " << someone.name << endl;[17;9H cout << "Age: " << someone.age << endl;[18;9H cout << "Test 1: " << someone.test1 << endl;[19;9H cout <<"Test 2: " << someone.test2 <<endl;[20;9H cout <<"Final: " << someone.final <<endl;[21;9H cout << "Student average: " << fixed << setprecision(1) << someone.avg << endl;[22;17Hcin.get(dummy);[23;9H cout <<"Input the name: ";[24;9H getline(cin, someone.name);[25;9H}[26;9H[K[27;9Htotal_age = avg_age/ class_size;[28;9Hclass_avg = class_total/ class_size;[K[29;9Hcout << "\nClass average: " << class_avg << fixed << setprecision(1) << endl;[30;9Hcout << "Average age of the class: " << fixed << setprecision(0) << total_age << endl;[31;17H[K[32;9Hcout << "\n\nDone.\n";[33;9Hreturn 0;[K[34;1H}[K[35;17H[K[36;17H[K[38;17H[K[39;17H[K[40;17H[K[41;17H[K[42;17H[K[43;17H[K[44;17H[K[45;17H[K[46;17H[K[25;1H[26;1H[48;1H[K[49;1H[K[acyurksaitis@zeus acyurksaitis]$ clear [H[J[acyurksaitis@zeus acyurksaitis]$ clearpico homework2.cpp1.cppexit[K./a.out Input the name: Amy Enter student's age: 32 Three exam scores: 88 88 188 Name: Amy Age: 32 Test 1: 88 Test 2: 88 Final: 188 Student average: 91.0 Input the name: Natalie Enter student's age: 11 Three exam scores: 100 100 200 Name: Natalie Age: 11 Test 1: 100 Test 2: 100 Final: 200 Student average: 100.0 Input the name: Chrissy Enter student's age: 14 Three exam scores: 100 100 100 Name: Chrissy Age: 14 Test 1: 100 Test 2: 100 Final: 100 Student average: 75.0 Input the name: P Class average: 88.7 Average age of the class: 19 Done. [acyurksaitis@zeus acyurksaitis]$ exit Script done on Wed 06 Feb 2008 08:16:56 PM EST