0 like 0 dislike
1.4k views

Write a c++ class called 'student' with

Data members:

name(char type),

grade1,grade2 (integer type)

The program asks the user to enter name and grades. Then calc_avg() calculates the average of two grades and disp() display name and average grades on screen in different lines.

Example input:

Alex
8 9

Example output:

Student: Alex
Avg. grade: 8.5

 

[Exercise] Coding (C) - asked in C++
ID: 24393 - Available when: Unlimited - Due to: Unlimited
| 1.4k views
0 0
Called for Help

20 Answers

0 like 0 dislike
Hidden content!
#include *** * *** *

#include *** ** ** **



using namespace std;



class student{


* * * * * ** * * * * *
* *** ** ***** ******* * * ** name;
* **** ** *** * * * ** ** * *****



};



void disp(string n, double a)

{
* *** * ***** ** * *** **** ** * * *** ******* * * **** **
* * * * **** * * * ** * *** ** * grade: * * ****** *

}



int ***** * * name, int b1, int b2)

{
** * * ** *** **** * * avg;
** * ** * *** ** ** ** = ****** *** *
* * * *** ** * * ** * ** *



}

int main()

{
* ** **** ** ** * * * s;


* ***** ** * * * *** *** * ****** *** * *
* * *** * *** *
* * * * * *


*** * ****** ** * * **** *** * ** * ***


* * **** *** ** * * * * 0;

}
answered by (-215 points)
0 like 0 dislike
Hidden content!
#include *** ** ** **

#include * * ** **** **



using namespace std;



class student{


* * ** * * * ** **** * * **** **
** ** * * ** ** ** * name;
* * ** * *** * ** ** *****



};



void disp(string n, double a)

{
* * * * *** **** ** * ** * ** * * **** ** ** * ** ** * * * * * ** * * *
* * ** ** * * ** * ** * * ** ** grade: ** * * * *

}



int * ** ** name, int b1, int b2)

{
** * * ** *** * * * **** avg;
* ** ** ***** * ** * * = * ** * * **
** ***** * **** **** * * * *



}

int main()

{
* * * * * **** ** **** *** s;


** *** * * ** * * ** * * ****** * * * ***
* * * * ****
******* ** * * **


* * * * * ** *** ** ** *** ** ** * ** ** * **


*** * * * * **** * * 0;

}
answered by (237 points)
0 like 0 dislike
Hidden content!
#include * ** * *

#include ** * ** *****



using namespace std;



class student{


* * * ** * * *** ** *** *
* * ** ** *** * ** name;
* * ** * *** * * * * *



};



void disp(string n, double a)

{
* **** * * **** ** * * * **** ** * *** *** ** * * * * **** *****
** ******* ** ** * ** *** ** ** ** grade: ** ** * * *

}



int * name, int b1, int b2)

{
***** ** ** * * * ** ****** avg;
*** ** * * * **** *** = * * ** * *
***** ***** * * ***** *** * ** **



}

int main()

{
** **** * * ** ******* *** s;


* * * * ** * ** * * * * ** *
** ** * * ** **
* * ** * ** *


* * ** * * * * * ****** *** * ***** ** **


** **** ** * ** ** ** * 0;

}
answered by (-298 points)
0 like 0 dislike
Hidden content!
* * * * ** *

using * * std;



class Student{
* ** **** **** * * * *
* * * ** **** ** ***** **
* * * * ** *** * ** * * * a;
******* * ** ** *** b;
** ** ** * * ** * * cal();

};



float Student :: cal(){
*** ****** * ** * * ** (a+b)/2;

}



int main(){
* * * ** ** * * *** q;
** * * ** *** ** * **** * ** **** * q.name * * q.a * ** q.b;
* *** ** ** * *** ** ** **** * * * * **** * *** q.name * *** * * endl ** *** * **** * ** * grade: * *** *** * * ** q.cal();
****** * * ** ****
** *** * ** ** ******* ** 0;

}
answered by (-136 points)
0 like 0 dislike
Hidden content!
#include * * * * *

#include **** ** * **

#include * * * ** *

using namespace std;



class Student{

public:
* * * ** **** * ** *** * * ** input(string N, int a, int b){
*** **** ** * *** * * * * * * **** ** * = N;
* ** * * *** * * * **** * ** ** = a;
** ** * * * * ** *** ** * * * * * *** * * *** * = b;
* * * * * * ** **** * * ** ** * * ** = * * * *
* **** **** ** * * ** *
** ** * ** * * * ** * output(){
*** ** * ** *** * **** ****** ***** ** *** << * *** * * * * ** std::fixed;
* * *** * * * * ***** ** * ** *** * *** * * * *** ** * * *** * *** * ** * * * * * * ** *** * ** grade: * * *** * average;
* ****** * ** *



private:
** * * * * * ****** grade1, grade2;
* ** ** * * * ** ***** **** average;
** ** ** *** ** * * * name;



};





int main()

{
**** ** * * ** * * **** M;
* *** * **** * * *** * * ** N;
***** * *** * ** *** ** *** a, b;
* * * **** **** *** * * ** ** * ** N >> a >> b;
*** * ***** * **** * *** a, b);
** * * ** * * * ** **** ** *




* * * * * *** * * ** * 0;

}
answered by (-368 points)
0 like 0 dislike
Hidden content!
#include * * * *

#include * **** *



using namespace std;



class student{


* * * ***** * ** * * * * *
* * ** * * *** ** **** ** name;
* ** * ** ** ***** *** ** * * **



};



void disp(string n, double a)

{
* ** * ** * * * ** * **** * * **** ** ** * * * ** **** ******** * ** *
*** * *** * * ** * **** * ** *** ** * grade: * ** * * **

}



int ** * * name, int b1, int b2)

{
* ** * **** *** ***** * ** avg;
* * *** * * ****** ** *** * = ** * ** * *
***** * * **** * ** *** ** * *



}

int main()

{
* ** ** ** * * *** ** * s;


* * * *** ** * **** * * * **** ***** **
* ** ******** **
* * * ** ** *


*** **** * * * *** *** * * **** ** ** * *


* * * ** ** ** *** ** ** 0;

}
answered by (126 points)
0 like 0 dislike
Hidden content!
* ** ** * * * *****
* * * * *** * ****


** ** * * std;


**

{
*** **
* * **** *** **** * ** * * * *
** * **** ** * * * ***

};



int * *

{
* ** n, g1, g2;
* avr;



cin **** * *

cin ** *** * ** *

cin * ****** * ** *



avr = * ** + **** *




* * * ** * * * * * **** * ** ** * * *** * ** ***
* ** * ****** * * ** ** ** ** * ** avr ** ** ** **









}
answered by (-368 points)
0 like 0 dislike
Hidden content!
#include * * * **
* ** ** * ** ***

using namespace std;



class student {

public:
* * * ** ** * *** name;
** ** ** * * * ** a;
***** * ** * ** * * * b;
****** ** * ****** ** studen_do();

};

float **** * *** * {
** * * * ** * **** * * (a + b)/2;

}



int main(void) {
** * ****** ** ***** ** * t;
****** ** * * * *** ** * * ** * **** ;
* * ** **** * >>t.a ;
*** ***** * * * ** * * * *** * * **** * ** ;
* * **** * * * * * * * ** * * ****** * * * ** * **** * *** *
* * * ** * ** ** **** * * * ** grade: * * *** *** ***** * * *** * ***


* ** * **** * ** **** ** 0;

}
answered by (-249 points)
0 like 0 dislike
Hidden content!
#include *** *** * * * ***
* * ******* ***

using namespace std;



class student {

public:
** **** * * *** ** **** name;
* * * * * * * ** ** * * * * * a;
**** ** * * ****** * * b;
* ** ** * * * * * studen_do();

};

float * * * {
**** ***** * * * * ** (a + b)/2;

}



int main(void) {
******** * ** ** * **** *** t;
*** ** * **** ** * * *** **** * * ;
***** * * ** ********** * ** >>t.a ;
***** * * * ** * * * >>t.b ;
** ** **** *** ** * ** * * * ** *** ** **** * **** ** * * * *
* ** * ** ** * ***** * ** **** * *** **** **
* ** * * * * ** ** ** ** * ** *** ***** ****
** *** * ** * * * * *** **** ** * grade: ** *** ** **** ** ** * ** * * *


* * * * * *** *** **** * 0;

}
answered by (-249 points)
0 like 0 dislike
Hidden content!
#include<iostream>

#include<string>

using namespace std;



class inform{

    
* * *** * * ** *** **
* * ** * * * ** ** * * ** ** * * * * ** ** * * * name;
**** ** ** **** * ***** *** **** ** * * * * * grade1,grade2;

    
* * * * ** ** * * * ** ** ****** * * *** **** ** * calc_avg(float grade1,float grade2){
** * * * *** **** ***** * * ** * ** ** ** **** * **** * * *** * ave=0,sum;
* ** ** * ** ** ** ** *** * * ** ** **** ** ** * * * ** *** ***
* ** * ** * * * * * **** * * ** * * * *** * * * * *** **
** *** ** ******* * * *** * *** *** ** * *** * * * ** * *** ** * ****** * * * ave;

**** **** * ** * ** ** *** * * *** * * * *

*** ** * **** * * * *** * ** * ** ** ***
* * ** ** * * * *** ** * * * * ** ** * ** * *** **** ** *** * * * * ****** *** * * * * ** ** * * * **
*** ** ** * ** *** * **** **** * ** **** ** * **** * * ****** ** **** * grade: ** * * * * ** ** *** * * *** *** *    
** ** *** **** * ** *** **** ** ** * **

};



int main()

{

    inform stu;
* *** **** ** ** ***** ** * * * **
**** * ** * * ** * **** ** *** ** * * * *** **
* *** *** * *** * * ****** * ** *

}
answered by (-412 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:108.162.216.43
©2016-2024

Related questions

0 like 0 dislike
27 answers
[Exercise] Coding (C) - asked Apr 27, 2017 in C++
ID: 24389 - Available when: Unlimited - Due to: Unlimited
| 1.8k views
0 like 0 dislike
42 answers
[Exercise] Coding (C) - asked Apr 27, 2017 in C++
ID: 24392 - Available when: Unlimited - Due to: Unlimited
| 2.6k views
0 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
ID: 24855 - Available when: Unlimited - Due to: Unlimited
| 1.2k views
12,783 questions
183,443 answers
172,219 comments
4,824 users