Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
