Intro to Java Web-Notes_Part10

Intro to Java Web-Notes_Part10 - Question 12(Worth 3 points...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Question 12 { (Worth 3 points) Decision Structures Give the output of the following Java program; , public Class HomEWOrk erupublic’static/Void’méin( “i int van Sys ryif’Kval’ 'Jelse TWO, ,,» Three ,Four "Five; j Even~., odd 43% OHSIV Five,j Even , , ThrEe' Four'7 Five Even One! ' ,Five' Odd Three ’Fiver, ",>, ( ( 0/ o , SyStemQOu 12;'VV ) ,30 :em,outtprintin(fohei"); val > 20) y:emfiout.prihtln("Two"i; vai”>71o>r I:em.out.println("Three“);“q' ;emtout.printlh("FoutV); 'System;out.println(“Five")r_ 2 :%'Or" y,ISystem.0ut;printlh("Even"); ’String i] argS) tfiprintinrfiodd"); Evenid Odd', Three Four Even H ,, , Poistt meat on ” “ Question 13 (Worth 3 points) Decision Structures - Writing Code Write an if-else statement that assigns the value 0.0 to a variable shipping if a variable cost is greater than or equal to 25, otherwise set shipping to 7.95. ESSAY SUBMISSION if (cost >= 25) { , , , shipping = 0,0; } , else , 3 shipping = 7.95; We“ Question 14 (Worth 3 pomts) Dialog Boxes - Writing Code Finish the code below so that it presents a dialog box that asks the user to enter the amount of a purchase. Your program will then report the amount of Michigan sales tax that is owed (multiply the user's amount by 0.06 to determine our six percent tax rate). Report the amount of tax owed via a dialog box. You Will need to covert the amount entered with the Double.parseDouble method. Test your solution in jGRASP to make sure that it works correctly. import javax.sWihg.JOptionPane;g/ pfiblitdclaSshsaleSTaX' 'uc public static veid main(String arQS) ~// WRITE THE'VCODE'THAT SHOULD ’GO HEREl ’ ESSAY SUBMISSION' String str; // For reading input. , double purchase; // The amount purchased. double tax; // The amOunt of tax ' double salesTaxH= 0.06; // Set sales tax multiplier , // Get the amount of purchases. , str— " JOptionPane. showlnputDialog("What Is the total ” "dellar amount of “ ”your pur'chases? ')+; , // Convert the input to a double. purchase :Double.parseDouble(str)’; // Calculate tax on purchases. tax= purchase* salesTax; ' // Display the result. JOptionPane. showMessageDialogmull, “Taxes owed on " + ”purchases Is $”+ tax); // End program. , System.exit(0); ...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern