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 trial

iOS Objective-C Basics Practicing with Immersive Examples Immersive example 2 - School’s Out

sabath rodriguez
sabath rodriguez
11,055 Points

Does 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

I 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
sabath rodriguez
11,055 Points

this is objective-c not swift, they're fundamentally different. I know swift but thanks.

Sorry man. I’m new to iOS and eager to help. Sorry to waste your time.