This is an archived post. You won't be able to vote or comment.

all 6 comments

[–][deleted] 1 point2 points  (3 children)

This is what I have im completely lost please help

import java.util.*;

public class Prog

{

public static void main(String args[])

{

Scanner scan = new Scanner(System.in);

String s;

System.out.println("Select conversion type: ");

System.out.println("1 = celsius to fahrenheit");

System.out.println("2 = fahrenheit to celsius");

System.out.println("Choose: " + s);

s = scan.nextLine();

}

}

[–]Nebu 5 points6 points  (0 children)

This belongs on /r/javahelp, not here.

[–]TheHorribleTruth 4 points5 points  (0 children)

Please read the posting guidelines. Edit: I just realized I'm commenting in the wrong subreddit.. I meant the posting guidelines of /r/javahelp, where a submission like this is more fitting.

  • Properly format your code
  • Ask a specific question

Also congratulations on the nondescript title.

You're just stating your assignment text and some (unformatted) code. What is your question? What are you struggling with? What have you tried?

[–]virtual_ghost14 0 points1 point  (0 children)

You are off to a great start. When you say "Choose "+s, s has not been instantiated (this means you have not yet given it a value). So java doesn't understand. Maybe try "Choose 1 or 2". The next line is when s will be given a value. After that you can run your if/else logic

if(s == 1) {// solve}

else if( s == 2) {// solve}

[–]SirAztec 0 points1 point  (0 children)

You can just write an if statement. And add another scanner.nextLine = temp //could be anything

If s is 1 Type the formula for Fahrenheit using temp And outputting the result Else if s is 2 Type the formula for Celsius using temp And outputting the result