Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialsabath rodriguez
11,055 PointsDoes my code work?
NSString *firstName = @"Sabath"; NSString *lastName = @"Rodriguez";
float classAverage = 70;
float finalAverage = 30;
int currentGradeLevel = 11;
if (currentGradeLevel >= 12) {
NSLog(@"Dear %@, congradulations! You have graduated! Don't forget to visit us!", firstName);
}
if ((finalAverage < classAverage) && currentGradeLevel < 12) {
NSLog(@"Dear %@, we look forward to seeing you at summer school, starting on July 1st!", firstName);
}
else if ((finalAverage <= classAverage) && currentGradeLevel < 12) {
currentGradeLevel++;
NSLog(@"dear %@, congradulations on a great year! We'll see you on july 1st, for the start of %ith grade!", firstName, currentGradeLevel);
}
1 Answer
Faraz Malik
20,721 PointsI think your code structure is fundamentally wrong, and I donโt mean to discourage you. I suggest you go over the swift basics course again, as it will help you a ton. Some of your code is mixed with python, so you might want co clear out your basics before you continue.
let firstName = โSabathโ
let lastName = โRodriguezโ
var classAverage: Float = 70.0
var finalAverage: Float = 30.0
var currentGradeLevel: Int = 11
if currentGradeLevel >= 12 {
print(โDear \(firstName), congratulations! Youโve graduated! Donโt forget to visit us!โ)
} else if (finalAverage < classAverage) && (currentGradeLevel < 12) {
print(โDear \(firstName), we look forward to seeing you at summer school, starting on July 1stโ)
} else {
currentGradeLevel += 1
print(โDear \(firstName), congratulations on a great year! We look forward to seeing you on July 1st, for the start of \(currentGradeLevel)th grade!โ)
}
sabath rodriguez
11,055 Pointssabath rodriguez
11,055 Pointsthis is objective-c not swift, they're fundamentally different. I know swift but thanks.
Faraz Malik
20,721 PointsFaraz Malik
20,721 PointsSorry man. Iโm new to iOS and eager to help. Sorry to waste your time.