0

I am using BlueJ as my IDE for this school project...

This is my code:

import java.util.Scanner;

public class Calculator{ 

public static void main(String[]args){

System.out.println("Enter your first number here:");

        Scanner input = new Scanner (System.in);

        double number1 = input.nextDouble();
        System.out.println(""); //Skipping a line for a better organised presentation

        System.out.println("Enter the second number here");
        double number2 = input.nextDouble();
        System.out.println(""); 

        double answer = number1 + number2;
        //code for highlighting the answer 
        System.out.println("The answer is:"+answer);

     }
}

I was working on this Calculator class then I thought about highlighting the answer to that it stands out more than the other numbers...

I've tried experimenting with JFrame before but it didn't quite work out for me...

Any suggestions? Thanks!

Benit
  • 1
  • 3
  • Possible duplicate of [How to change text color in the JtextArea?](https://stackoverflow.com/questions/9650992/how-to-change-text-color-in-the-jtextarea) – Mark Jeronimus Jun 05 '18 at 10:29
  • Possible duplicate of [How to print color in console using System.out.println?](https://stackoverflow.com/questions/5762491/how-to-print-color-in-console-using-system-out-println) – Michael Jun 05 '18 at 10:30
  • Or if you want to stick to the console, you can use this: https://stackoverflow.com/a/25683444/829571 – assylias Jun 05 '18 at 10:30
  • The default console doesn't support any formatting at all. More advanced consoles exist but are difficult to get used to (they don't run in an IDE like BlueJ). A `JFrame` is your only easy-ish option. – Mark Jeronimus Jun 05 '18 at 10:31
  • GUI toolkits seem a little out of your reach at the moment and the console only supports colours on unix / cygwin. Honestly, I really wouldn't worry about making purely aesthetic changes like this at the moment. – Michael Jun 05 '18 at 10:33
  • @MarkJeronimus so if I try to use Eclipse to work out this project will those advanced consoles run? – Benit Jun 05 '18 at 10:52
  • @Benit afaik it doesn't work in any IDE. – Mark Jeronimus Jun 05 '18 at 10:57
  • @MarkJeronimus Thanks – Benit Jun 05 '18 at 11:00

0 Answers0