Introduction to programming 12 - Variables Exercise 01

preview_player
Показать описание
Are you interested in becoming a software developer and don't know where to start? Worry not dear friend, start here.

Introduction to programming logic using Java is a course designed to get your first step in software development, no matter your background. In this course you are going to learn the basics of algorithms and how to tell the computer to do something for you.

At the end of this course you will be capable of designing simple algorithms using Java, understand concepts that are common across all programming languages, and be able to move one step further in your software development career.

Рекомендации по теме
Комментарии
Автор

My solution:

public class ExerciseAgeDifference {

public static void main(String[] args) {

int age1 = 18;
int age2 = 20;

int difference = age2 - age1;

System.out.println("First Age: " + age1);
System.out.println("Between age: " + difference);
System.out.println("last age: " + age2);

}

}

herculessantos
Автор

there is a small problem in this code, if I pass a smaller value for the first age, it would result in a negative age. it is a challenge for those who are starting to create a valid logic where applying a lower or higher age results in the right difference.

rmls.
welcome to shbcf.ru