Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1 : check the code and psudo code is correct or not and give me desk check for this Input Processing Output parcel _
Question : check the code and psudo code is correct or not and give me desk check for this
Input Processing Output
parcelweight Prompt for parcelweight
Get parcelweight
Check if weight is exit condition
Adjust weight ceil if max kg
Calculate deliverycharge
Display deliverycharge deliverycharge
A pseudo code algorithm
BEGIN
FUNCTION main
CREATE scanner for input
WHILE true DO
PROMPT "Enter parcel weight in kg to exit:
TRY
READ weight
IF weight THEN PRINT "Invalid weight. Please enter a positive number." CONTINUE
CATCH InputMismatchException
PRINT "Please enter a valid number." CLEAR input
IF weight THEN PRINT "Exiting program..." EXIT loop
IF weight THEN weight ceilingweight
IF weight THEN weight PRINT "Weight adjusted."
deliveryCharge calculateDeliveryChargeweight
PRINT "Delivery charge: $ deliveryCharge
ENDWHILE
CLOSE scanner
END FUNCTION
FUNCTION calculateDeliveryChargeweight
IF weight THEN RETURN ELSE IF weight THEN RETURN ELSE RETURN weight
END FUNCTION
END
import java.util.InputMismatchException;
import java.util.Scanner;
public class DeliveryService
public static void mainString args
Scanner scanner new ScannerSystemin;
while true
System.out.printEnter parcel weight in kg to exit: ;
double weight;
try
weight scanner.nextDouble;
if weight
System.out.printlnInvalid weight. Please enter a positive number.";
continue;
catch InputMismatchException e
System.out.printlnPlease enter a valid number.";
scanner.nextLine; Clear the invalid input
continue;
if weight
System.out.printlnExiting program...";
break;
if weight
weight Math.ceilweight;
if weight
weight ;
System.out.printlnWeight adjusted to maximum allowed kg;
double deliveryCharge calculateDeliveryChargeweight;
System.out.printlnDelivery charge: $ deliveryCharge;
scanner.close;
public static double calculateDeliveryChargedouble weight
if weight
return ;
else if weight
return ;
else
return weight ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started