a) Find and correct the errors in the program below. b) Determine the value of ticketCost in the following program for each of the input conditions on the right: import java.io.* /* Class MovieCost Author: Date: Description: Sponge Bob Sept. 2007 Calculates the cost of a movie based on the input from the user. */ public class MovieCost { public static void main(String args[]) throws Exception { Buffered Reader kb = new Buffered Reader(new InputStreamReader(System.in)); // input show time from the keyboard System.out.print("Please enter the time of show: ('M' for Matinee or 'E' for Evening): "); char showTime=kb.readLine().charAt(0); // input input ticket type from the keyboard System.out.print("Please enter the type of ticket: ('C' for Child or 'A' for Adult): "); char ticketType = Integer.parseInt(readLine()); // calculate the cost of the ticket double ticketCost = cale TicketCost( showTime, ticketType); // output the cost of the ticket System.out.println("The cost of your ticket is " + ticketCost); } // main method /* method to calculate the cost of a movie ticket given the show time and ticket type */ public static int calcTicketCost (char show Time, String ticketType) { ICS4U0 double ticketCost = 0; // initialize the cost to 0 if (showTime=='M' && ticketType == 'C') ticketCost = 4.50; if (show Time == 'E' && ticketType == 'C') ticketCost = 5.50; if (show Time == 'M' && ticketType == 'A') ticketCost = 8.00; if (show Time == 'E' && ticketType=='A') ticketCost = 10.50; return ticketCost; }//cale TicketCost method } // MovieCost class The best computer is your mind Heart Lake Secondary School 2) Determine the number of loop iterations for each of the following: for (int i = 0; i<10; i++) for (int i= 1; i <10; i++) for (int i = 0; i<100; i = 2) for (int i = 1; i < 50; i+= 2) for (int i = 1000; i > 10; i--) for (int i = 5; i < 150; i+= 5) 1. M, A ticket Cost: 2. E, A ticketCost 3. E.C ticketCost: 4. M, C ticketCost: Page 1 of 3 Computer Studies

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Please help me with this using java
a) Find and correct the errors in the program below.
b)
Determine the value of ticket Cost in the following program for each of the input
conditions on the right:
import java.io.*
/* Class MovieCost
Author:
Date:
Description:
Sponge Bob
Sept. 2007
Calculates the cost of a movie based on the input from the
user. */
public class Movie Cost
{
public static void main(String args[]) throws Exception
{
BufferedReader kb = new Buffered Reader(new InputStreamReader(System.in));
// input show time from the keyboard
System.out.print("Please enter the time of show: ('M' for Matinee or 'E' for Evening): ");
char showTime= kb.readLine().charAt(0);
// input input ticket type from the keyboard
System.out.print ("Please enter the type of ticket: ('C' for Child or 'A' for Adult): ");
char ticketType = Integer.parseInt(readLine());
// calculate the cost of the ticket
double ticketCost = calc Ticket Cost( showTime, ticketType);
// output the cost of the ticket
System.out.println("The cost of your ticket is " + ticketCost);
} // main method
/* method to calculate the cost of a movie ticket given the show time and ticket
type */
public static int caleTicketCost (char showTime, String ticketType)
{
ICS4UO
double ticket Cost = 0; // initialize the cost to 0
if (showTime=='M' && ticketType == 'C')
ticketCost = 4.50;
if (showTime== 'E' && ticketType == 'C')
ticketCost = 5.50;
if (showTime=='M' && ticketType == 'A')
ticketCost = 8.00;
if (showTime=='E' && ticketType=='A')
ticketCost = 10.50;
return ticketCost;
} // cale TicketCost method
} // MovieCost class
The best computer is your mind
Heart Lake Secondary School
2) Determine the number of loop iterations for each of the following:
for (int i = 0; i <10; i++)
for (int i = 1; i <10; i++)
for (int i = 0; i < 100; i+= 2)
for (int i= 1; i < 50; i+= 2)
for (int i= 1000; i > 10; i--)
for (int i= 5; i < 150; i+= 5)
1. M, A
ticketCost:
2. E, A
ticketCost:
3. E, C
ticket Cost:
4. M, C
ticketCost:
Page 1 of 3
Computer Studies
Transcribed Image Text:a) Find and correct the errors in the program below. b) Determine the value of ticket Cost in the following program for each of the input conditions on the right: import java.io.* /* Class MovieCost Author: Date: Description: Sponge Bob Sept. 2007 Calculates the cost of a movie based on the input from the user. */ public class Movie Cost { public static void main(String args[]) throws Exception { BufferedReader kb = new Buffered Reader(new InputStreamReader(System.in)); // input show time from the keyboard System.out.print("Please enter the time of show: ('M' for Matinee or 'E' for Evening): "); char showTime= kb.readLine().charAt(0); // input input ticket type from the keyboard System.out.print ("Please enter the type of ticket: ('C' for Child or 'A' for Adult): "); char ticketType = Integer.parseInt(readLine()); // calculate the cost of the ticket double ticketCost = calc Ticket Cost( showTime, ticketType); // output the cost of the ticket System.out.println("The cost of your ticket is " + ticketCost); } // main method /* method to calculate the cost of a movie ticket given the show time and ticket type */ public static int caleTicketCost (char showTime, String ticketType) { ICS4UO double ticket Cost = 0; // initialize the cost to 0 if (showTime=='M' && ticketType == 'C') ticketCost = 4.50; if (showTime== 'E' && ticketType == 'C') ticketCost = 5.50; if (showTime=='M' && ticketType == 'A') ticketCost = 8.00; if (showTime=='E' && ticketType=='A') ticketCost = 10.50; return ticketCost; } // cale TicketCost method } // MovieCost class The best computer is your mind Heart Lake Secondary School 2) Determine the number of loop iterations for each of the following: for (int i = 0; i <10; i++) for (int i = 1; i <10; i++) for (int i = 0; i < 100; i+= 2) for (int i= 1; i < 50; i+= 2) for (int i= 1000; i > 10; i--) for (int i= 5; i < 150; i+= 5) 1. M, A ticketCost: 2. E, A ticketCost: 3. E, C ticket Cost: 4. M, C ticketCost: Page 1 of 3 Computer Studies
Expert Solution
Step 1

The solution to both the questions given below with code screenshot

Happy Coding ?

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Top down approach design
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education