评分系统 java_C自动评分系统
我無(wú)法按照規(guī)范完成作業(yè) . 這是分配方案:
大學(xué)迫切需要一個(gè)自動(dòng)測(cè)試評(píng)分系統(tǒng) . 使用C,為大學(xué)寫(xiě)一個(gè)評(píng)分系統(tǒng),并對(duì)至少五名學(xué)生的測(cè)試進(jìn)行評(píng)分 . 要?jiǎng)?chuàng)建評(píng)分系統(tǒng),請(qǐng)按照以下步驟操作:首先詢問(wèn)測(cè)試中的問(wèn)題數(shù)量然后詢問(wèn)每個(gè)問(wèn)題的正確答案 . 請(qǐng)注意,多項(xiàng)選擇測(cè)試和問(wèn)題將從A到D得到答案 . 詢問(wèn)學(xué)生人數(shù)并通過(guò)詢問(wèn)他們的姓名來(lái)處理每個(gè)學(xué)生,然后循環(huán)詢問(wèn)學(xué)生的答案 . 為每個(gè)問(wèn)題打分 . 在最后一個(gè)問(wèn)題計(jì)算出學(xué)生得分后,顯示“學(xué)生'插入學(xué)生姓名'得分為20分中的10分或50% . ”重復(fù),直到所有學(xué)生都得分 . 在對(duì)所有學(xué)生進(jìn)行評(píng)分后,以與以前相同的方式插入打印所有學(xué)生成績(jī)的 class 列表 .
這是我到目前為止:
#include "stdafx.h"
#include
#include
#include
#include
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
//declare variables
char choice;
string studentName;
vector answers;
vector names;
int getStudents();
int getQuestions();
//calls function to get number of questions
float questions = getQuestions();
//Get answers
for (int i = 0; i < questions; ++i) {
cout << "What is the answer for question " << i + 1 << endl;
cin >> choice;
answers.push_back(choice);
}
//Get number of students
int students = getStudents();
//Get student names
for (int i = 0; i < students; i++) {
cout << "Student " << i + 1 << ", what is your name?" << endl;
cin >> studentName;
names.push_back(studentName);
}
float score = 0;
char studentAnswer;
vector userAnswer;
vector finalScore;
//gets student answers
for (int i = 0; i < students; i++) {
for (int j = 0; j < questions; j++) {
cout << names[i] << ", what is your answer for question " << j + 1 << "?" << endl;
cin >> studentAnswer;
userAnswer.push_back(studentAnswer);
}
}
//calculates student scores
for (int i = 0; i < students; i++) {
for (int j = 0; j < questions; j++) {
if (userAnswer[j] == answers[j])
score = score + 1;
}
finalScore.push_back(score);
}
//outputs scores
for (int i = 0; i < students; i++) {
cout << names[i] << " scored " << finalScore[i] << " out of " << questions <<
" or " << (finalScore[i] / questions) * 100 << "%" << endl;
}
system("pause");
return 0;
}
//function to get number of questions
int getQuestions()
{
int questions;
cout << "How many questions are there?" << endl;
cin >> questions;
return questions;
}
//function to get number of students
int getStudents()
{
int students;
cout << "How many students are there?" << endl;
cin >> students;
return students;
}
最終得分返回的值不準(zhǔn)確,我找不到錯(cuò)誤發(fā)生的位置 .
同樣,為了在最后一步中進(jìn)行排序,我被要求按升序或字母順序按降序和名稱排序 . 我能夠相互獨(dú)立地排序這些,但不知道如何將它們組合起來(lái)并按照這種方式對(duì)它們進(jìn)行排序 .
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的评分系统 java_C自动评分系统的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: php 打包上传的文件,PHP单文件上传
- 下一篇: 通过Daffodil for VS使VS