• Hello Guest! Did you know that ProjectKorra has an official Discord server? A lot of discussion about the official server, development process, and community discussion happens over there. Feel free to join now by clicking the link below.

    Join the Discord Server

Exercise Help

HydroMan

Verified Member
Now it says that it has found bugs after analyzing my code -__-
Code:
public class BetterHello {

   public static void main(String[] args) {
      String greeting = "Hello Martians I am";
     int age = 27;
  }

}
 
Last edited:

AlexTheCoder

Staff member
Plugin Developer
Verified Member
Now it says that it has found bugs after analyzing my code -__-
Code:
public class BetterHello {

   public static void main(String[] args) {
      String greeting = "Hello Martians I am";
     int age = 27;
  }

}
You aren't outputting anything. System.out.(etc) is needed to print information
 

OmniCypher

Staff member
Lead Developer
Administrator
Plugin Developer
LOL!

I see the issue... You have been attempting to use
Code:
System.out.printIn();
instead of
Code:
System.out.println();
It should be lowercase "LN" for line not "IN"
 

HydroMan

Verified Member
LOL!

I see the issue... You have been attempting to use
Code:
System.out.printIn();
instead of
Code:
System.out.println();
It should be lowercase "LN" for line not "IN"
Lol, at forst when i watcb the tutorial in video, the "I" was unclear and look liked very strange so i assume it was low capital "l". After I realise with "in" it would make sense, because it's actual word, so that's why i added it :p.
 

HydroMan

Verified Member
ok so i fixed it, now the bug notes that there is no "years old" output in my code. So how do i add those final words?
 

HydroMan

Verified Member
Pretty much the same, except with the last change.
Code:
public class BetterHello {

public static void main(String[] args) {
String greeting = "Hello Martians I am";
int age = 27;

System.out.println(greeting + " " + age);

}

}
 

Finn_Bueno_

Staff member
Plugin Developer
Verified Member
Pretty much the same, except with the last change.
Code:
public class BetterHello {

public static void main(String[] args) {
String greeting = "Hello Martians I am";
int age = 27;

System.out.println(greeting + " " + age);

}

}
What's the error then? Also, you don't have to put
Code:
System.out.println(greeting + " " + age);
You can simply add a space to
Code:
String greeting = "Hello Martians I am ";
 

HydroMan

Verified Member
Now i came across with the 5th exersice problem. I seriously what it wants and i don't know what i should do. Here's what it says:
Problem:
You and the Martian start becoming good friends. There is so much in common between the two of you - an interest in camping on volcanic peaks to hunting for quarters in the swimming pool. One summer afternoon, you and your Martian friend decide to play a game of Echo. The purpose of the game is to echo what the other person is saying. If the Martian says "zboggattyu", you have to reply back with "zboggattyu".
The exercise below, asks you to enter some text on the system console. This text will be stored in the variable 'someText'. This is then copied into another variable called '-echo', which is printed back to the system console. However, we are unable to get the code to compile. You have to get the code to compile, so you can play echo with your Martian friend.

What we expect:
Primarily, we expect you to get the code to compile. Once the code is compiled and run, it will ask you to enter a String on the system console. We expect the same String is echoed (printed) back on the system console.

Hint:
There are some rules governing valid variable names

Learning Outcomes:
After completing this exercise, you should have learned what constitutes a valid variable name.
Here's the code:
Code:
import java.util.Scanner;
public class Echo {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("maaaaartiianaaa");
        String someText = scanner.next();
        String echo = "";
        ///{
    
        //start your coding here 
                // 
        ///}  
                System.out.println(echo);
    }
}
Now just tell me where i should i start working on. To what line should i give attention to. Givee an hint. And I'll do every rest to myself.
 
Last edited:

HydroMan

Verified Member
Now i came across with the 5th exersice problem. I seriously what it wants and i don't know what i should do. Here's what it says:


Here's the code:
Code:
import java.util.Scanner;
public class Echo {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("maaaaartiianaaa");
        String someText = scanner.next();
        String echo = "";
        ///{
   
        //start your coding here
                //
        ///} 
                System.out.println(echo);
    }
}
Now just tell me where i should i start working on. To what line should i give attention to. Givee an hint. And I'll do every rest to myself.
Solved it. Just needed the error = someText; to add.

but now i have another problem...
Problem:
You and your Martian friend go hiking up Mount Vesuvius. While exchanging stories at the campfire, he tells you about this grocer on Mars. He says, "Ze is the best grocer in this galaxy, but you have to respect ze wishes." It seems Ze sells only two items - Zomatoes, and Zinions. But that's not all. Ze will not sell you an arbitrary number of items. The minimum order is 65 and the maximum order is 122. What's more, you cannot ask for 65 Zomatoes. You have to ask for 'A' Zomatoes. Similarly, you cannot ask for 122 Zinions. You have to ask for 'z' Zinions. Confused ? The ASCII value of (uppercase) 'A' is 65 and the ASCII value of (lowercase) 'z' is 122.
In this exercise you have to add the ASCII values of 2 char variables.

What we expect:
In this exercise, Ze will ask you for the number of Zomatoes and Zinions you want to buy. You have to enter an ASCII character in the range [A-Za-z] for both. The number of Zomatoes you want to buy will be given to you in a variable called 'zomatoes', which is of type 'char'. The number of 'Zinions' you want to buy will be given to you in a variable called 'zinions', which is also of type char. You have to add the ASCII values of both the char variables (zomatoes and zinions) and populate the variable called 'items', which is of type 'int', with the sum. For example if you asked for 'a' Zomatoes and 'C' Zinions, the total number of items is 'a'(97) + 'C'(67) = 164

Hint:
Typecasting ! nuff said.
I had set up on how think it should be. But it says that my code's output is 14)
Code:
import java.util.Scanner;
public class CrazyConverter {
    public static void main(String args[]) {        
        Scanner scanner = new Scanner(System.in);
        System.out.println("Hello I am your friendly grocer Darth: ");
        System.out.println("How many zomatoes do you want ? a");
        String sZomatoes = scanner.nextLine();
        System.out.println("How many zinions do you want ? C");
        String sZinions = scanner.nextLine();
        
        char zomatoes = sZomatoes.charAt(98);
        char zinions = sZinions.charAt(67);
        int  items = 165;
        ///{
  
                //start your coding here 
                  
                //end

        ///}
        
        System.out.println("Thank you ! you have asked for " + items + " items");
    }
}
 

jedk1

New Member
Problem:
You and your Martian friend go hiking up Mount Vesuvius. While exchanging stories at the campfire, he tells you about this grocer on Mars. He says, "Ze is the best grocer in this galaxy, but you have to respect ze wishes." It seems Ze sells only two items - Zomatoes, and Zinions. But that's not all. Ze will not sell you an arbitrary number of items. The minimum order is 65 and the maximum order is 122. What's more, you cannot ask for 65 Zomatoes. You have to ask for 'A' Zomatoes. Similarly, you cannot ask for 122 Zinions. You have to ask for 'z' Zinions. Confused ? The ASCII value of (uppercase) 'A' is 65 and the ASCII value of (lowercase) 'z' is 122.
In this exercise you have to add the ASCII values of 2 char variables.

What we expect:
In this exercise, Ze will ask you for the number of Zomatoes and Zinions you want to buy. You have to enter an ASCII character in the range [A-Za-z] for both. The number of Zomatoes you want to buy will be given to you in a variable called 'zomatoes', which is of type 'char'. The number of 'Zinions' you want to buy will be given to you in a variable called 'zinions', which is also of type char. You have to add the ASCII values of both the char variables (zomatoes and zinions) and populate the variable called 'items', which is of type 'int', with the sum. For example if you asked for 'a' Zomatoes and 'C' Zinions, the total number of items is 'a'(97) + 'C'(67) = 164

.... these seem like something from a math GCSE paper @Loony xD
 
Top