Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Postage calculation with negative weight error message. Improve the program by also outputting The next higher weight is ___ with a cost of ___ cents.
Postage calculation with negative weight error message.
Improve the program by also outputting "The next higher weight is ___ with a cost of ___ cents".
1 import java.util.scanner; 2 3 public class PostageCalc 4 public static void main (String [1 args) Scanner scnr new Scanner (System.in); final int NUM. ELEMENTS = 14; // Weights in ounces double [] letterwWeights 11.0, 2.0, 3.0, 3.5, 4.0, 5.0, 6.0 8 9 7.0, 8.e, 9.0, 10.0, 11.0, 12.0, 13.0; Costs in cents (usps.com 2017) int[] postageCosts 49, 70, 91, 112, 161, 182, 203, 224, 245, 266, 287, 308, 329, 350); 12 13 14 15 double userLetterweight; boolean foundWeight; int i; Prompt user to enter letter weight System.out.print("Enter letter weight (in ounces): "): userLetterweight scnr.nextDouble); 17 19 20 21 Postage costs is based on smallest letter weight greater than /1 or equal to mailing letter weight foundweight false; 23 24 25 26 27 28 29 30 for (i-0; (i
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