Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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.

 

 

Java, Programming

  • Category:- Java
  • Reference No.:- M91348642
  • Price:- $15

Guranteed 24 Hours Delivery, In Price:- $15

Have any Question?


Related Questions in Java

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As