结算等级 [英] Calcluating Grades

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

问题描述




我正在尝试计算一个人的成绩,这是我的代码:


//目的:计算成绩为给定商标授予的代码

//参数:商标用于计算等级代码

// Ret.Val:作为角色的等级

//上一个:已经达到了标记

//帖子:等级是根据相关计算的

常数

//返回。


char getGrade(双重标记){


if(mark> = 85)printf(" High Distinction") ;

else if(mark> = 75)printf(" Distinction");

else if(mark> = 65)printf(" Credit") ;

else if(mark> = 50)prinf(" Pass");

else printf(" Fail Grade");

printf(" \ n");

返回0.0;

}


当我编译代码时,我收到错误信息,禁止比较
指针和整数之间的
。我知道你可以通过开关

statmen做,但我不确定如何去做。有人可以指导我

正确的方向。


提前致谢。


Greg

Hi

I am trying to calculate a persons grade, here is my code:

// Purpose: To calculate the grade code awarded for a given mark
// Arguments: mark is used to calculate grade code
// Ret.Val: The grade as a character
// Pre: The mark has been attained
// Post: The grade has been calculated according to relevant
constants
// and returned.

char getGrade(double mark) {

if (mark >=85) printf("High Distinction");
else if (mark >=75) printf("Distinction");
else if (mark >=65) printf("Credit");
else if (mark >=50) prinf ("Pass");
else printf("Fail Grade");
printf("\n");
return 0.0;
}

When I compile the code, I get error message the it forbids comparison
between pointer and integer. I know that you can do via switch
statmen, but am unsure on how to go about it. Could someone direct me
the correct direction.

Thanks in advance.

Greg

推荐答案

Gregc。写道:


我正在尝试计算一个人的成绩,这是我的代码:

//目的:计算成绩代码给定标记奖励
//参数:标记用于计算等级代码
// Ret.Val:作为角色的等级
// Pre:标记已经达到
//帖子:评分是根据相关的
常数
//返回的。

char getGrade(双重标记){
if(mark> = 85)printf(" High Distinction");
else if(mark> = 75)printf(" Distinction");
else if(mark> = 65)printf(Credit);
else if(mark> = 50)prinf(" Pass");
else printf(" Fail Grade");
printf (\ n);
返回0.0;
}

当我编译代码时,我得到错误信息它禁止比较点之间呃和整数。我知道你可以通过开关
统计,但我不确定如何去做。有人可以指导我
正确的方向。
Hi

I am trying to calculate a persons grade, here is my code:

// Purpose: To calculate the grade code awarded for a given mark
// Arguments: mark is used to calculate grade code
// Ret.Val: The grade as a character
// Pre: The mark has been attained
// Post: The grade has been calculated according to relevant
constants
// and returned.

char getGrade(double mark) {

if (mark >=85) printf("High Distinction");
else if (mark >=75) printf("Distinction");
else if (mark >=65) printf("Credit");
else if (mark >=50) prinf ("Pass");
else printf("Fail Grade");
printf("\n");
return 0.0;
}

When I compile the code, I get error message the it forbids comparison
between pointer and integer. I know that you can do via switch
statmen, but am unsure on how to go about it. Could someone direct me
the correct direction.




请复制并粘贴实际的程序和错误信息。我的猜测

就是你已经将getGrade定义为指向双倍的指标而不是双倍但我们为什么要猜?向我们展示真实的

的事情。


Robert Gamble



Please copy and paste the actual program and error message. My guess
would be that you have defined getGrade as taking a pointer to double
instead of a double but why should we have to guess? Show us the real
thing.

Robert Gamble


Gregc。写道:
我正在尝试计算人员等级,这是我的代码:

//目的:计算给定商标的等级代码
//参数:标记用于计算等级代码
// Ret.Val:作为角色的等级
//前:已经达到标记
//帖子:等级已经根据相关的
常数
//计算并返回。


这些是C ++评论。如果您使用它们而不是更标准的/ * * /

C注释,您可能会遇到可移植性问题(如果您关心那个

)。

char getGrade(double mark){

if(mark> = 85)printf(" High Distinction");
else if(mark> = 75)printf(" ;区分);
否则if(mark> = 65)printf(" Credit");
else if(mark> = 50)prinf(" Pass");
else printf(失败等级);
printf(" \ n");
返回0.0;
}

当我编译代码时,我收到错误消息,禁止在指针和整数之间进行比较。


问题在于返回类型。你已声明函数

返回一个char,但已返回一个浮点数。鉴于这个函数

的作用,我会将返回类型更改为void并且不返回任何内容(即:

return;)

[.. 。]我知道你可以通过开关声明来做,但我不确定如何去做。
I am trying to calculate a persons grade, here is my code:

// Purpose: To calculate the grade code awarded for a given mark
// Arguments: mark is used to calculate grade code
// Ret.Val: The grade as a character
// Pre: The mark has been attained
// Post: The grade has been calculated according to relevant
constants
// and returned.
These are C++ comments. You may experience portability problems (if
you care about that) if you use them instead of the more standard /* */
C comments.
char getGrade(double mark) {

if (mark >=85) printf("High Distinction");
else if (mark >=75) printf("Distinction");
else if (mark >=65) printf("Credit");
else if (mark >=50) prinf ("Pass");
else printf("Fail Grade");
printf("\n");
return 0.0;
}

When I compile the code, I get error message the it forbids comparison
between pointer and integer.
The problem is with the return type. You have declared the function to
return a "char", but have returned a float. Given what this function
does, I would change the return type to void and return nothing (i.e.:
return;)
[...] I know that you can do via switch statment, but am unsure on how to go about it.




开关声明对你没有帮助。开关只对

有用,可在有限数量的可能输入之间进行选择(双倍

*范围*不是。)


-

Paul Hsieh
http:/ /www.pobox.com/~qed/
http:// bstring .sf.net /



A switch statement would not help you here. Switch is only useful for
selecting between a finite number of possible inputs (which double
*ranges* are not.)

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/


" Robert Gamble" < RG ******* @ gmail.com>写道:
"Robert Gamble" <rg*******@gmail.com> writes:
Gregc。写道:


我正在尝试计算一个人的成绩,这是我的代码:

//目的:计算成绩代码给定标记奖励
//参数:标记用于计算等级代码
// Ret.Val:作为角色的等级
// Pre:标记已经达到
//帖子:评分是根据相关的
常数
//返回的。

char getGrade(双重标记){
if(mark> = 85)printf(" High Distinction");
else if(mark> = 75)printf(" Distinction");
else if(mark> = 65)printf(Credit);
else if(mark> = 50)prinf(" Pass");
else printf(" Fail Grade");
printf (\ n);
返回0.0;
}

当我编译代码时,我得到错误信息它禁止比较点之间呃和整数。我知道你可以通过开关
统计,但我不确定如何去做。有人可以指导我
正确的方向。
Hi

I am trying to calculate a persons grade, here is my code:

// Purpose: To calculate the grade code awarded for a given mark
// Arguments: mark is used to calculate grade code
// Ret.Val: The grade as a character
// Pre: The mark has been attained
// Post: The grade has been calculated according to relevant
constants
// and returned.

char getGrade(double mark) {

if (mark >=85) printf("High Distinction");
else if (mark >=75) printf("Distinction");
else if (mark >=65) printf("Credit");
else if (mark >=50) prinf ("Pass");
else printf("Fail Grade");
printf("\n");
return 0.0;
}

When I compile the code, I get error message the it forbids comparison
between pointer and integer. I know that you can do via switch
statmen, but am unsure on how to go about it. Could someone direct me
the correct direction.


请复制并粘贴实际的程序和错误信息。我的猜测
就是你已经将getGrade定义为指向双倍而不是双倍但我们为什么要猜?向我们展示真实的东西。

Please copy and paste the actual program and error message. My guess
would be that you have defined getGrade as taking a pointer to double
instead of a double but why should we have to guess? Show us the real
thing.



或者该函数声称返回一个字符,但返回一个浮点数

(如果有的话)不要被那个缩进所迷惑。)

我怀疑错误不在上面的函数中,而是它的调用。


-

Chris。


Or that the function claims to return a char, but returns a float
(if one''s not fooled by that indentation).
I suspect the error is not in the function above, but its calling.

--
Chris.


这篇关于结算等级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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