编程分配查找 [英] Programming Assignment Lookover

查看:74
本文介绍了编程分配查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的任务:



设计并实施一个等级计算器,根据许多参数显示最终等级。成绩基于5个分配分数,2个中期分数和1个最终测试分数计算。程序例程要求:(i)5个作业中的每一个的作业分数,(ii)中期1和2分,以及(iii)最终考试分数。然后,它根据每个组件的权重计算最终的总分数;您的程序必须向用户询问这些重量。根据最终总分,屏幕上会打印A,B,C或D等级。



计算成绩还有一个附加条款。如果学生在第一周参加期末考试,并且考试成绩超过70分,那么无论作业和考试内容如何,​​学生都会获得A.您的程序应该能够提出问题以捕获有关学生的所有上述信息并在屏幕上显示正确的最终成绩。



检查+或更多:获得奖励积分,使等级计算器尽可能逼真。不假设任务或中期数量,而是让用户通过提出问题并了解评分如何适用于该特定课程来告诉您这些事情。



--- -------------------------------------------------- -------------------------------------------------- ----



我已经把我的代码编译好了,运行得很好......但是,当把它们放入等级时它们似乎没有正常计算,比如,如果我为每个等级加一个90,我做A = 90,B = 80,C = 70,D = 60,我最终得到D平均值。任何关于如何改变这一点的建议将不胜感激。



-------------------- -------------------------------------------------- -------------------------------------



Here is my assignment:

Design and implement a grade calculator that displays the final grade based on a number of parameters. Grades are calculated based on 5 assignment scores, 2 midterm scores and one final test score. The program routines asks for: (i) assignment score for each of the 5 assignments, (ii) midterm 1 and 2 scores, and (iii) final test score. It then calculates the final aggregate score based the weightage for each of these components; your program must ask for these weightages from the user. Based on the final aggregate score, a grade of either A, B, C or D is printed on screen.

There is an additional clause to calculating grade. If a student takes the final exam in the first week, and gets more than 70, the student get's an A regardless of assignments and midterms. Your program should be able pose questions to capture all the abovestated information about a student and display the correct final grade on screen.

Check+ or more: To get bonus points, make the grade calculator as realistic as possible. Assume nothing about the number of assignments or midterms, instead let the user tell you these things by posing questions and understanding how grading works for that particular course.

-----------------------------------------------------------------------------------------------------------

I have gotten my code to compile and it runs fine...however, when putting in grades they don't seem to be computing properly, such as if I put a 90 in for every grade, I and make A=90, B=80, C=70, D=60, I will end up with a D average. Any advice as to how I should change this will be greatly appreciated.

-----------------------------------------------------------------------------------------------------------

// Assignment02.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include <iostream>
#include "string"
using namespace std;

int main()
{
	//Declaring variables
	start:

	string class_name = "";

	string response;
	string response2;
	int retake;

	float homework_percent;
	int homework = 0;
	float homework_grade;
	float homework_grade_total = 0;
	int x = 1;

	float midterm_percent;
	int midterm=0;
	float midterm_grade;
	float midterm_grade_total = 0;
	int y = 1;

	float final_exam_percent;
	float final_exam_grade;

	float final_average;

	float A_grade;
	float B_grade;
	float C_grade;
	float D_grade;

	string final_response;

	//Introduction
	cout << "Welcome to the Grade Calculator! This program will assist you in finding your final average for a class. To begin, enter the name of your class: ";
	cin >> class_name;
	
	//First Week Final Exam Option
	cout << "\n\nBefore we begin, did you take the final exam during the first week of class? ";
	cin >> response;

	if (response == "yes" || response == "Yes" || response == "YES")
	{
		cout << "\nWhat was your score? ";
		cin >> final_exam_grade;

		if (final_exam_grade > 70)
		{
			cout << "\n\nCongradulations! You have passed the course, " << class_name << ". You really know your stuff!";

			system("Pause");

			goto restart;
		}
		else
		{
			cout << "Sorry, you are going to have to take the course. Would you like to retake the final exam? ";
			cin >> response2;

			if (response2 == "yes" || response2 == "Yes" || response2 == "YES")
			{
				retake = 1;
			}
			else
			{
				retake = 0;
			}
		}
	}

	//Homework grade
	cout << "\nWhat percent of your grade is composed of homework assignments? ";
	cin >> homework_percent;
	homework_percent = homework_percent / 100;

	cout << "How many homework assignments do you have? ";
	cin >> homework;

	while (homework > 0)
	{
		cout << "\nEnter grade for homework assignment number " << x << ": ";
		cin >> homework_grade;
		homework_grade_total = homework_grade_total + homework_grade;
		homework--;
		x++;
	} 
	homework_grade_total = homework_grade_total / x;

	//Midterm grade
	cout << "\n\nWhat percent of your grade is composed of midterm assignments? ";
	cin >> midterm_percent;
	midterm_percent = midterm_percent / 100;

	cout << "How many midterm assignments do you have? ";
	cin >> midterm;

	while (midterm > 0)
	{
		cout << "\nEnter grade for midterm number " << y << ": ";
		cin >> midterm_grade;
		midterm_grade_total = midterm_grade_total + midterm_grade;
		midterm--;
		y++;
	}
	midterm_grade_total = midterm_grade_total / x;

	//Final Exam grade
	if (retake = 1)
	{
		cout << "\n\nWhat percent of your grade is the final exam? ";
		cin >> final_exam_percent;
		final_exam_percent = final_exam_percent / 100;

		cout << "\nEnter grade for final exam: ";
		cin >> final_exam_grade;
	}

	//Calculator (this is where is gets FUN!)
	final_average = (homework_grade_total*homework_percent) + (midterm_grade_total*midterm_percent) + (final_exam_grade*final_exam_percent);
	
	system("Pause");

	//Result
	cout << "\nWhat is the minimum grade required to recieve an 'A'? ";
	cin >> A_grade;
	cout << "What is the minimum grade required to recieve a 'B'? ";
	cin >> B_grade;
	cout << "What is the minimum grade required to recieve a 'C'? ";
	cin >> C_grade;
	cout << "What is the minimum grade required to recieve a 'D'? ";
	cin >> D_grade;

	if (final_average >= A_grade)
	{
		cout << "\n\nCongradulations! You have passed the course, " << class_name << " , with an A average. You really know your stuff!\n\n";

		system("Pause");
	}
	else if (final_average >= B_grade && final_average < A_grade)
	{
		cout << "\n\nCongradulations! You have passed the course, " << class_name << " , with a B average. You did a solid job.\n\n";

		system("Pause");
	}
	else if (final_average >= C_grade && final_average < B_grade)
	{
		cout << "\n\nCongradulations! You have passed the course, " << class_name << " , with a C average. You seem to grasp the material.\n\n";

		system("Pause");
	}
	else if (final_average >= D_grade && final_average < C_grade)
	{
		cout << "\n\nCongradulations! You have passed the course, " << class_name << " , with a D average. Just made it (sigh of relief).\n\n";

		system("Pause");
	}
	else
	{
		cout << "\n\nUnfortunately, you have failed the course. But do not worry, you can always retake it.\n\n";

		system("Pause");
	}

	//Option to restart program
	restart:

	cout << "\nWould you like to run the calculator again? ";
	cin >> final_response;

	if (final_response == "yes" || final_response == "Yes" || final_response == "YES")
	{
		system("Clear");
		goto start;
	}
	else
	{
		return 1;
	}
}

推荐答案

midterm_grade_total = midterm_grade_total / x;



应该是


should be

midterm_grade_total = midterm_grade_total / y;



代替。



我猜这是一个CopyPasteException;)我们都遇到过这一次。


instead.

I guess it's a CopyPasteException ;) We've all met that once.


这篇关于编程分配查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆