我正在尝试在考试结束时向用户显示百分比。基本上我需要一行代码,将myScore除以70的问题总数。任何帮助都会非常感激。
以下是我考试结束的代码:
NSInteger endOfQuiz = [theQuiz count];
if((((questionNumber - 1) * 6) + 6) == endOfQuiz)
{
// Game is over.
if(myScore >= 49 )
{
NSString *finishingStatement = [[NSString alloc] initWithFormat:@"Practice Exam concluded. Congratulations, you have passed with a 70%% or better! \nYou scored %i out of 70!", myScore];
theQuestion.text = finishingStatement;
answerResult.text = @"";
counterLabel.text = @""; }
else
{
NSString *finishingStatement = [[NSString alloc] initWithFormat:@"Practice Exam concluded. Unfortunately, you have failed with less than 70%%, keep practicing! \nYou scored %i out of 70.", myScore];
theQuestion.text = finishingStatement;
counterLabel.text = @"";
}
theLives.text = @"";
answerResult.text = @"";
// Make button 1 appear as a reset game button
restartGame = YES;
[answerOne setHidden:NO];
[answerOne setTitle:@" Try this Practice Exam again" forState:UIControlStateNormal];
}
答案 0 :(得分:0)
c中的除法运算符(因而是Objective-C)是/
。
myScore * 100 / 70