Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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);
}
}

2.1 Lab2a Due Sep-19 Introduction Here is the program scenario: At a bicycle rental shop, there are unicycles, bicycles, and tandem bicycles available. A group of people want to ride and the program needs to calculate the total cost of the group rental. Background Reading Horstmann, Chapter 2.1-2. This program is similar to the Ticket Seller program in your Course Reader Grading This lab is worth 10 points. ZyBook will give you a score out of 10, however, the grader will also review your code to give suggestions or corrections. If a program is written in such a way that it merits a major correction, a loss of points may occur Task You are to write a Java program that prompts the user to enter a number for each type of transportation. Use System.out.println method to output the message 1. The prompt should read exactly: Enter unicycles, bicycles, tandems 2. Following this, use the Scanner class to read in 3 whole numbers to represent each transportation type in order. When defining your variables, choose a data type that represents whole numbers When the program runs, you can enter the three numbers on one line or separate lines. Try it both ways. Example input: 08 3 3. Next your program will calculate the total cost. Rental prices are $2.50 for unicycles, $5.00 for bicycles, and $8.00 for tandem bicycles (a tandem bike has two seats). When defining the cost, choose a data type that represents a fractional (floating point) number. Note that it is not necessary to define a variable to store the cost, but it may make your program more easy to read 4. Finally your program should output the cost calculated in step 3 preceded by the String "Total rental cost is $'" Example: Enter unicycles, bicycles, tandems Total rental cost is $64.0 Don't worry that the program doesn't print $64.00. We will have an opportunity to learn to format output later in the semester.

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.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote