Java coding if-else while loop

Assignment Help JAVA Programming
Reference no: EM13778479

1. Based on the code below, answer these questions (identify line numbers for Java statements):

Which line(s) will be executed if the condition in line 3 is true?
Processing then will proceed to which line?

Which line(s) will be executed if the condition in line 3 is false?
Processing will then proceed to which line?

Line 10 will always be executed whether line _____ is true or false.

Lines 5-6 will only be executed when line ______ is ____________.
Line 9 will only be executed when line ______ is ____________.

 

1 double purchasesYTD = 200.0;

2 double discount = 0.0;

3 if(purchasesYTD>= 200.00)

4 {

5 System.out.printf("%nUse this promo code on your next purchase ME09X1.");

6 discount = .10;

7 }

8 else

9 System.out.printf("%nPlease check our daily specials.");

10 System.out.printf("%nYou qualify for a %.0f%% discount.", discount);

2. Re-code the IF/ELSE structure in lines 3-9 above so the else statement is now the if statement. HINT: The condition tested should be reversed.

3. Use printf() with format specifiers as needed. Code on this page the following:

a. Code an if statement that prints "I got the promotion!". The if condition tests the boolean variable promotion which is already declared.

b. Given a boolean variable called inactive,use the conditional operator (ternary operator) to assign ‘Y' to the variable closeAcct; otherwise, assign‘N'. Assume both variables are already declared.

c. Write an if-else statement that assigns 2 extra credit points for an 80% class attendance rate, 3 extra credit points for an 85% class attendance rate, and 5 extra credit points for anything 90% and above. Assume extraCreditand attendancearealready declared. Make sure you scope the code properly

d. Code a while loop that keeps printing "You are a DEDICATED student!" as long as the user enters an attendance rate of 90% or greater. Assume the loop-control variable, attendance, is already declared along with input for the Scanner class. The while loop requires a priming read for the loop-control variable prior to entering the loop.

e. There are 20 students. Code a while loop that processes extra credit points for student attendance. Use the if/else coded in 3c. Print "Sorry, you've not earned any extra credit for your attendance." or "Congratulations! You've earned 9extra credit points because of your good attendance." where the 9 is the actual number of points earned based on the if/else from 3c. Assume the input variable for the Scanner class, the attendanceand extraCreditvariables are already declared. Declare the loop-control variable.

 

 

Reference no: EM13778479

Questions Cloud

Describe how the sox act may affect ethical decision : Write a 350- to 700-word review of the article. Your review should discuss how the SOX Act may affect ethical decision making in today's business environment, and the criminal penalties for which the act provides
Arrested for assaulting : Two men were arrested for assaulting each other in what would be called a "bar brawl." The bar owner did not press charges, and the two men were released.
State of decision making and problem diagnosis : Which of the steps in the formal planning process involves studying past events, examining current conditions, and forecasting future trends?
Stereotypes set by culture and society : Sociology came into existence in the 19th century to explain the enormous changes occasioned by the Industrial Revolution, urbanization, and an individualistic mind-set. Unlike agrarian communities, the emerging urban populations were large, numbe..
Java coding if-else while loop : Code a while loop that keeps printing "You are a DEDICATED student!" as long as the user enters an attendance rate of 90% or greater. Assume the loop-control variable, attendance, is already declared along with input for the Scanner class. The w..
Strongly counter-intuitive consequences : Review the Food Environment Atlas maps for variables that seem to affect your selected state the most. Select a state and variables you consider relevant to represent the food environment in you chosen state.
Meaningfulness of a correlation coefficient : What is the coefficient of determination? Why is it important to know the amount of shared variance when interpreting both the significance and the meaningfulness of a correlation coefficient?
How to create both method contract and method specification : Your demonstrations of how to create both method contract and the method specification for the GetCourseByCourseID() method of the CourseList class were very well received by your team members
When making basic marks and marginal comments : When making basic marks and marginal comments, which strategy is LEAST helpful? Which of the following steps do not help writers develop research topics into appropriate lines of inquiry?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Define javascript and servlet

The web site must be built using one of these techniques. JavaScript and servlet

  Own file to test your program

Create your own file to test your program. Your job is to set up the input and output files to have the program read from a file and write to a file. Here is a basic program that will accomplish what is desired

  Write programs that read a line of input

Write programs that read a line of input as a string and input

  If you are using the blackboard mobile learn app please

if you are using the blackboard mobile learn app please click view in browser. technical project address bookthis

  Implement a recursive method that returns xn

implement a recursive method that returns xn - Suppose we want methods that compute the value of a double precision number raised to an integer power.

  Create a gui client side application that is a java version

q1. create a gui client side application that is a java version of notepad giving the ability to open modify and save

  In this project you need to write a java program called

in this project you need to write a java program called mm.java to perform matrix multiplication. your code will read

  Java socket hello i need to this assignment done in net

hello i need to this assignment done in net beans . and i want comment in code .also screen shots of running program

  Java application to carry out additions and subtractions

Design a Java application to carry out additions and subtractions for numbers of any length. A number is represented as an object which includes a sign and two strings for the whole and decimal parts of the number.

  1 what makes a program easy to modify2 describe the order

1. what makes a program easy to modify?2. describe the order of magnitude of the following code section using bigo

  Create a gui application with jframe

Create a GUI application with JFrame that contains five labels describing reasons that a customer might not buy a specific product (e.g. too expensive).

  Create the look for two gui applications

Create the look for two GUI applications. You WILL NOT be getting the applications to do anything. We are only interested in seeing how well you can arrange the GUI components onto the window

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd