What's new

Closed Need Help

Status
Not open for further replies.

XieSmile

Eternal Poster
Joined
Feb 8, 2019
Posts
1,113
Reaction
390
Points
347
Patulong po mga ka phc, about po sa looping yung tanong ko.

Paano po ma display yung dalawa sa data? 1.png kasi po yung ikatatlo kasi po yung na didisplay di ko po alam if ano yung kulang sa code para ma display yung sa taas.

Self taught lang po ako at may kaunting kaalaman tungkol sa programming. Grading System po sana toh sa subject namin. Pinapagawa ng teacher namin.

Ito po yung code sa program. 3.png4.png5.png sana po matulongan niyo po ako sa problema ko. Thank you
 

Attachments

di ko magets kung ako gusto mo idisplay :( tulungan sana kita . reply ka lang para matulungan kita
 
ay nagets ko na. meron ka pa palang ibang input sa taas . kumbaga gusto mo gumawa ng parang table tama ba?
 
array ang need mo pang multiple gagamitin mo para di makahirapan sa pag store sa variables
 
kung fixed sa 3 display gawin mo nalang static. para di ka mahirapan. pero kung paiba iba ung dami need mo gumamit ng for loop
 
hi ts! nireview ko yung source mo, doon sa LINE 36 sa for loop mo, nao-override 'yung values everytime naglalagay ka ng data using 'cin', kaya ang ma-a-output lang niya 'eh yung last data table input mo na "Rodrigo Roa Duterte".

para di mangyari yun, either create variable arrays ng mga values para mai-index mo sila, then call for loop to output those arrays

post mo source mo para mas madali namin ma-check :)
 
#include <iostream>
#include <iomanip>
#include <string>
#include <istream>
#include <string.h>

using namespace std;

int main()
{
/*SN = Student Name
SUB = Subject
REM = Remarks
PL = PreLim
MT = MidTerm
ET = EndTerm
SUM = Summation
AVE = Average*/

string SN,SUB,REM;
float PL,MT,ET;
int SUM,AVE;

for (int CTR=0; CTR<3; CTR++)
{
//Input Operation
cout <<"Enter Student Name:";
getline(cin,SN);
cout << "" << SN <<endl;
cout <<"Enter Subject:";
getline(cin,SUB);
cout << "" << SUB <<endl;
cout <<"Enter Prelim Grade:";
cin >>PL;
cin.ignore();
cout << "" << PL <<endl;
cout <<"Enter Midterm Grade:";
cin >>MT;
cin.ignore();
cout << "" << MT <<endl;
cout <<"Enter Endterm Grade:";
cin >>ET;
cin.ignore();
cout << "" << ET << "\n" <<endl;

}
{
cout <<"Computing Data......" << "\n" <<endl;
}
{
//Display output data
cout << setw(16) <<"Student Name";
cout << setw(18) <<"Subject";
cout << setw(20) <<"Final Grade";
cout << setw(15) <<"Remark"<<endl;
}
{
//Process
SUM = PL+MT+ET;
AVE = SUM/3.0;
AVE = SUM/3;
}
//if else section
if(AVE>=5.0)
{
cout << setw(10) << SN;
cout << setw(17) << SUB;
cout << setw(13) << AVE;
cout << setw(20) << "PASSED"<<endl;
}
else
if(AVE<=5.0)
{
cout << setw(10) << SN;
cout << setw(17) << SUB;
cout << setw(13) << AVE;
cout << setw(20) << "FAILED"<<endl;
}
else
if(AVE>=5)
{
cout << setw(10) << SN;
cout << setw(17) << SUB;
cout << setw(13) << AVE;
cout << setw(20) << "PASSED"<<endl;
}
else
if(AVE<=5)
{
cout << setw(10) << SN;
cout << setw(17) << SUB;
cout << setw(13) << AVE;
cout << setw(20) << "FAILED"<<endl;
}
else

return 0;
}
 
C++:
#include <iostream>
#include <iomanip>
#include <stdio.h>

using namespace std;

int students = 3;

// student name, subject, remarks
string sn[3], sub[3], rem; // version-safe declaration

// prelim, midterm, endterm
float pl[3], mt[3], et[3]; // version-safe declaration

// ariths
float sum;
float avg;

int main() {
    // counter
    for(int ctr = 0; ctr < students; ctr++) {
       
        cout << "Enter student name: ";
        getline(cin, sn[ctr]);
        cout << sn[ctr] << endl;
       
        cout << "Enter subject: ";
        getline(cin, sub[ctr]);
        cout << sub[ctr] << endl;
       
        cout << "Enter Prelim Grade: ";
        cin >> pl[ctr];
        cout << "" << pl[ctr] << endl; // concat
       
        cout << "Enter Midterm Grade: ";
        cin >> mt[ctr];
        cout << "" << mt[ctr] << endl; // concat
       
        cout << "Enter Endterm Grade: ";
        cin >> et[ctr];
        cout << "" << et[ctr]  << "\n\n"; // concat
       
    cin.ignore(); // unstream cin
    }

    cout << "Computing Data..." << "\n\n"; // notifier

    // frame template
    cout << setw(16) << "Student Name";
    cout << setw(18) << "Subject";
    cout << setw(20) << "Final Grade";
    cout << setw(15) << "Remarks";

    cout << endl; // separator

    for(int ctr = 0; ctr < students; ctr++) {

        // ariths
        sum = pl[ctr] + mt[ctr] + et[ctr];
        avg = sum / (float) students;

        if (avg > 5) {
            rem = "PASSED";
        } else {
            rem = "FAILED";
        }

        cout << setw(10) << sn[ctr];
        cout << setw(17) << sub[ctr];
        cout << setw(13) << avg;
        cout << setw(10) << rem;

        cout << endl; // separator
    }


}

eto version ko, working 'yan, hindi ako gumagamit ng setw() kaya baka may mali ako sa alignment.

kung gusto mo ma-calculate pati fraction (e.g. 16.667) , just use float data type sa calculation mo, pati sa container variable :)
 
Status
Not open for further replies.

Similar threads

Back
Top