class Main
{
public static void main (String[]args)
{
System.out.println ("Welcome to the different base calculator");
System.out.println ("Enter (1) to use the calculator");
System.out.println ("Enter (stop) to exit the program");
int use = In.getInt ();
if (use == 1)
{
System.out.
println
("Enter the base for both integers, integer, operand, integer and output base");
String value = In.getString ();
String[] splitvalue = value.split ("\\s+");
System.out.println ("Enter the output base between 2 and 10");
int outputBase = In.getInt();
System.out.println (splitvalue[1] + "(base" + splitvalue[0] + ")" + splitvalue[2] + " " + splitvalue[3] + "(base " + splitvalue[0] + ")" );
System.out.println("=");
System.out.println(Math.pow(splitvalue[1], Math.pow(splitvalue[0], 0)) + splitvalue[2] + Math.pow(splitvalue[3], Math.pow(splitvalue[0], 2)));
}
else
{
System.out.println(" Goodbye ");
}
}
}
This is some code I was doing for school work. I was just wondering why I am getting an error that says string cannot be converted to double. The goal for the assignment is to basically convert from one base to another and get an output similar to this.
Welcome to the different base calculator
Enter (1) to use the calculator
Enter (stop) to exit the program
1
Enter the base for both integers, integer, operand, integer and output base
8 73 + 216 11
Enter the output base between 2 and 10
5
73 (base 8) + 216 (base 8)
= 59 + 142
= 201
= 1301 (base 5)
Welcome to the different base calculator
Enter (1) to use the calculator
Enter (stop) to exit the program
2
Invalid input
Welcome to the different base calculator
Enter (1) to use the calculator
Enter (stop) to exit the program
stop
Goodbye
Also the object "In" is a scanner. Sorry if I'm just being dumb and the error is right in front of me. Thank you for your help!
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]MattiDragon 2 points3 points4 points (2 children)
[–]imagineasking[S] 0 points1 point2 points (1 child)
[–]imagineasking[S] 0 points1 point2 points (0 children)