using System;public static class Lab3_2{public static void Main(){// declare the variables and constantsconst double FLAT = 1.25;double weight;double cost, pricePerKg = 0;// Input the weightConsole.Write("Enter a positive weight of the package => ");weight = Convert.ToDouble(Console.ReadLine());// Determine the cost per kilogramif (weight <= 0)Console.WriteLine("*** Invalid weight");else if (weight < 1)pricePerKg = 0.25;else if (weight <= 3.5)pricePerKg = 0.5;else (weight > 3.5)pricePerKg = 1.0;// Compute the cost to send the packageif (weight > 0)cost = weight * pricePerKg + FLAT; elsecost = 0;// Output the resultsConsole.WriteLine("The cost to send the package is {0:C}",cost);Console.ReadLine();}} Remove the syntax error from my code and run it for input weight 2.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question
100%

using System;public static class Lab3_2{public static void Main(){// declare the variables and constantsconst double FLAT = 1.25;double weight;double cost, pricePerKg = 0;// Input the weightConsole.Write("Enter a positive weight of the package => ");weight = Convert.ToDouble(Console.ReadLine());// Determine the cost per kilogramif (weight <= 0)Console.WriteLine("*** Invalid weight");else if (weight < 1)pricePerKg = 0.25;else if (weight <= 3.5)pricePerKg = 0.5;else (weight > 3.5)pricePerKg = 1.0;// Compute the cost to send the packageif (weight > 0)cost = weight * pricePerKg + FLAT;
elsecost = 0;// Output the resultsConsole.WriteLine("The cost to send the package is {0:C}",cost);Console.ReadLine();}}

Remove the syntax error from my code and run it for input weight 2.

Attach the outputs.

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Reference Types in Function
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT