1 / 3

Spot the mistakes!

Spot the mistakes!. public class PetAge { public static void main(String[] args ) { String petname ; boolean petage ; petname = Rollo ; potage = 6 ; System.out.println ("My pet's name is " + petname ) System.out.println ( petname +" is "+ petage + " years old ." ; } }

jamar
Télécharger la présentation

Spot the mistakes!

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. Spot the mistakes! public class PetAge { public static void main(String[] args) { String petname; booleanpetage; petname = Rollo; potage= 6; System.out.println("My pet's name is " + petname) System.out.println(petname+" is "+ petage+ " years old."; } } Hint: there are 5 of them

  2. Answers. Data type should be int not boolean. A String should have speech marks. Variable names should always be spelled the same. There should always be a semi colon at the end of a line of code. Brackets that are opened must be closed. public class PetAge { public static void main(String[] args) { String petname; booleanpetage; petname = Rollo; potage= 6; System.out.println("My pet's name is " + petname) System.out.println(petname+" is "+ petage+ " years old."; } } Well done if you found them all.

  3. Correct code. public class PetAge { public static void main(String[] args) { String petname; intpetage; petname = "Rollo"; petage= 6; System.out.println("My pet's name is " + petname); System.out.println(petname+" is "+ petage+ " years old."); } } Remember to be precise when writing your code.

More Related