Monday, March 28, 2011

Homework 2














#include <iostream.h>
main ()

{
     //variable
     float sub1,sub2,sub3,sub4,sub5,cpa;
     //input1
     cout<<"insert subject1:";
     cin>>sub1;
     //input2
     cout<<"insert subject2:";
     cin>>sub2;
     //input3
     cout<<"insert subject3:";
     cin>>sub3;
     //input4
     cout<<"insert subject4:";
     cin>>sub4;
     //input5
     cout<<"insert subject5:";
     cin>>sub5;
     //process
     cpa=((sub1*3)+(sub2*3)+(sub3*2)+(sub4*2)+(sub5*4))/5;
     //output
     cout<<"subject 1:"<<sub1<<endl;
     cout<<"subject 2:"<<sub2<<endl;
     cout<<"subject 3:"<<sub3<<endl;
     cout<<"subject 4:"<<sub4<<endl;
     cout<<"subject 5:"<<sub5<<endl;
     cout<<"CPA is:"<<cpa<<endl;
     return 0;
     }

No comments:

Post a Comment