Uploading week 1 Exercise 9 to the server

94 views
Skip to first unread message

gsay...@gmail.com

unread,
Dec 4, 2015, 12:28:45 PM12/4/15
to mooc.fi
Hi,

I'm having problems with week 1 exercise 9

My problem has to do with uploading it to the server.

compile:
run:
Type a number: 3
Type another number; 2
Division: 3 / 2 = 1.5
BUILD SUCCESSFUL (total time: 8 seconds)

Program Code

import java.util.Scanner;

public class Divider {

    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        
        // Implement your program here. Remember to ask the input from user.
        System.out.print("Type a number: ");
        int num1 = Integer.parseInt(reader.nextLine());
        System.out.print("Type another number; ");
        int num2 = Integer.parseInt(reader.nextLine());
        double result = (double)num1 / (double)num2;
        String display = "Division: 3 / 2 = ";
        System.out.println(display + result);
        
    }
}

Below is my Green Button Results

compile:
run:
Type a number: 3
Type another number; 2
Division: 3 / 2 = 1.5
BUILD SUCCESSFUL (total time: 8 seconds)


The link to my work is here: http://paste.mooc.fi/d22262c6

Best regards

Saydee

ljleppan

unread,
Dec 7, 2015, 3:39:10 AM12/7/15
to mooc.fi
Hi,

You need to replace the numbers 3 and 2 in the output with whatever numbers the user inputs. So if the user inputs the numbers 2 and 1, then the output should be "Division: 2 / 1 = 1".

-Leo

Geetor Saydee

unread,
Jan 16, 2016, 7:49:22 PM1/16/16
to mooc.fi
Thanks,

The trick was 
"double result1 = 1.0 * num1 / num2;
System.out.println("Division: " + num1 + " / " + num2 + " = " + result1);"

It did work as I replaced the numbers 3 and 2 in the output with whatever numbers the user inputs.

Thanks
Reply all
Reply to author
Forward
0 new messages