我試圖在考試結束時向用戶顯示百分比。基本上,我需要一行代碼,將myScore除以70的問題總數。任何幫助都將非常感謝。在目標C中顯示百分比
這是我的考試結束碼:
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];
}
那麼,什麼是錯'浮動比例= 100×(浮動)將myScore/70;「(你乘以100得到的百分比。) – Caleb