Hello I need help editing my code here are the directions along with my code tha
ID: 3886910 • Letter: H
Question
Hello I need help editing my code here are the directions along with my code that I created:
Import java.util.*;
public class Lab2a {
public static void main(String[] args) {
Scanner int = new Scanner (System.in)’
int unicycles;
int bicycles;
int tandems;
Double price = 0;
//prompt user for kayaks, cones, and rowBoats
System.out.printIn(“Enter unicycles, bicycles, tandems”);
Unicycles = in.nextInt();
Bicycles = in.nextInt();
Tandems = in.nextInt();
price = (2.50 * unicycles + 5.0 * bicycles + 8.0 * tandems)
System.out.print(“Total rental costs is 4”);
System.out.printIn(price);
}
}
Explanation / Answer
Hi, your code is logically correct but not syntactically, i have corrected it below,
Import java.util.*;
public class Lab2a {
public static void main(String[] args) {
Scanner s = new Scanner (System.in); // scanner is a type, so variable name cant be int
int unicycles;
int bicycles;
int tandems;
Double price = 0.0; //since its double, we have to use 0.0
//prompt user for kayaks, cones, and rowBoats
System.out.println("Enter unicycles, bicycles, tandems");
unicycles = s.nextInt();
bicycles = s.nextInt();
tandems = s.nextInt();
price = (2.50 * unicycles + 5.0 * bicycles + 8.0 * tandems);
System.out.print("Total rental costs is $"); //dollar symbol used as given in question
System.out.println(price); //its printLn not printIn, changed that
}
}
Thumbs up if this was helpful, otherwise let me know in comments. Good Day.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.