1 / 8

CS001 Introduction to Programming Day 6

CS001 Introduction to Programming Day 6. Sujana Jyothi ( sujana @cs.nuim.ie ). What will you learn today?. Learn to write programs Use the Java programming language. File HelloTester.java. public class HelloTester {

Download Presentation

CS001 Introduction to Programming Day 6

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS001Introduction to ProgrammingDay 6 Sujana Jyothi (sujana@cs.nuim.ie)

  2. What will you learn today? • Learn to write programs • Use the Java programming language

  3. File HelloTester.java public classHelloTester { public static void main(String[] args) { // Display a greeting in the console windowSystem.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); } }

More Related