completely new to java, not new to coding [message #1802483] |
Sun, 10 February 2019 15:22 |
zohaib khurshid Messages: 2 Registered: February 2019 |
Junior Member |
|
|
whats wrong with this code?
Quote:package src;
import java.util.Scanner;
public class Class1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// System.out.print(" weight ");
int weight = 98;
//HOW TO SKIP STATEMENT INCASE CONDITION NOT MET
if (weight >= 100)
{
System.out.print("Please enter your gender as" +
" 'F'or 'M ");
//String gender = input.next();
String gender = "F";
}
int size = (weight/10);
//System.out.format("Size is %d ", size); to check size value
//category
String category = "Snow";
System.out.print(" enter TYPE" +
" 'H' for Hiking or 'B' for Backcountty ");
Scanner scanner = new Scanner(System.in);
String type = scanner.nextLine();
if (type == "H"){
type = "Hiking";
}
else if (type == "B")
{
type = "Backcountry";
}
System.out.format("type is %d", type);
String result = String.format("The price for a %s snowshoes in %s, size %d is $ %d", type, "category",25, 300);
}
}
Quote:
This is the error message i am getting
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method format(String, Object[]) in the type PrintStream is not applicable for the arguments (String, String)
The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
The method format(Locale, String, Object[]) in the type String is not applicable for the arguments (String, String, String, int, int)
at Class1.main(Class1.java:40)
im using eclipse
Version: Helios Service Release 1
Build id: 20100917-0705
[Updated on: Sun, 10 February 2019 16:05] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.08800 seconds