Download presentation
Presentation is loading. Please wait.
Published byMarjorie Peters Modified over 8 years ago
1
CS001 Introduction to Programming Day 6 Sujana Jyothi (sujana@cs.nuim.ie)sujana@cs.nuim.ie
2
2 What will you learn today? Learn to write programs Use the Java programming language
3
3 File HelloTester.java public class HelloTester { public static void main(String[] args) { // Display a greeting in the console window System.out.println(“hello, world"); } } public class HelloTester { public static void main(String[] args) { // Display a greeting in the console window System.out.println(“hello, world"); } } Output hello, world
4
Statement System.out.println(“hello, world”);
5
Example in Java
6
// Program to find the average of three numbers public class Average { public static void main(String[] args) { int number1 = 5; int number2 = 4; int number3 = 7; int sum = number1+number2+number3; int average = sum/3; System.out.println(“Sum is " + sum); System.out.println(" Average is" + average); }
7
Program to find if the first number is greater than or less than or equal to the second number public class Maximum { public static void main(String[] args) { int x = 10; int y = 20; // complete this }
8
// Program Multiples calculates the square and cube of a value public class Multiples { public static void main(String[] args) { int VALUE = 5; System.out.println("The number is " + VALUE); int VALUE1 = VALUE*VALUE; System.out.println(“squared is " + VALUE1); int VALUE2 = VALUE*VALUE*VALUE; System.out.println(" cubed is " + VALUE2); }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.