Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Question 1. Collect two integer values from the user. Based on these values display the sum, difference, product, average, distance (absolute difference), maximum and minimum. Sample output is provided below:

C:\Users\aaron\Desktop>java
Enter two integers:
10
20
Sum:30
Difference:-10
Product:200
Average:15.0
Distance:10
Maximum:20
Minimum:10

C:\Users\aaron\Desktop>java
Enter two integers:
101 52
Sum:153
Difference:49
Product:5252
Average:76.5
Distance:49
Maximum:101
Minimum:52
Do the same work outlined above BUT have the output aligned in the following manner:

C:\Users\aaron\Desktop>java
Enter two integers:
101 52
Sum: 153
Difference: 49
Product: 5252
Average: 76.5
Distance: 49
Maximum: 101
Minimum: 52

Question 2. Write a program that prompts the user to enter three number grades. The program then computes the average of the three grades and displays the letter grade for the three original grades and for the average. Letter grades are computed as follows:

• A+: 90-100
• A: 80-89
• B: 70-79
• C: 60-69
• D: 50-59
• F: < 50
See the sample output below for clarification.

C:\Users\aaron\Desktop>java question2
Please enter three number grades...
First grade: 80
Second grade: 76
Third grade: 68
First Grade: A
Second Grade: B
Third Grade: C
Average: B

Question 3. Write a Java application that is designed to help you determine the winner of a video game contest. The program takes in the names and points-scored of three competitors. Then it prints out who came in first (highest score), who is second and who is third (lowest score). If any of the scores are < 0, stop the program with an error immediately. See my example output below:

C:\Users\aaron\Desktop>java question3

Please enter the three competitor's names, separated by a new line:
John
Sally
Mark
Please enter John's score: 10000
Please enter Sally's score: 12000
Please enter Mark's score: 9750
First place: Sally!
Second place: John!
Third place: Mark!

Amend your program so that if there is a tie, that is taken into account. For example, if the top two players are tied, they are both awarded first place and the remaining player gets third. If the last two players are tied they both get second. If all three players are tied they all get first, and so on.

Note: Do not use Arrays, ArrayLists, or sorting algoritms to solve this question.

Question 4. Consider a cell phone provider with three data plans.

Plan A: $30 per month, 250 MB included. $10 per 250 MB above that.
Plan B: $40 per month, 1 GB included. $10 per 500 MB above that.
Plan C: $65 per month, 6 GB included. $10 per 1 GB above that.
Prompt the user to enter their plan letter and then the total number of GBs of data they used that month. If the total data used was less than 0 GB, quite the program immediately. Otherwise, compute and display their total charges.

C:\Users\aaron\Desktop>java

Please enter the letter corresponding to your plan: B
Please enter the amount of data you used (in GB): 2.5
Your total charges are $70

Arguably, for high data users, Plan A is the worst! If the user selected Plan A, show them how much they could have saved if they were using Plan B and C. If they selected Plan B, show them how much they could have saved using Plan C. Note: If NO savings could have been realized, do not show them the alternate plans.

Question 5. Write a java application that determines whether a user-entered integer is odd or even and whether it is evenly divisible by 3, 4, both 3 and 4 or neither 3 nor 4 (see my output below for clarification).

Assume the user will enter a positive integer. The output from my solution is shown below. Do your best to duplicate my output. Below is my output from running the program 5 times. Use boolean operators (&& or ||) in your solution.

C:\Users\aaron\Desktop>java

Enter an integer:12
12 is even.
12 is divisible by 3 and 4.

C:\Users\aaron\Desktop>java

Enter an integer:9
9 is odd.
9 is divisible by 3.

C:\Users\aaron\Desktop>java

Enter an integer:16
16 is even.
16 is divisible by 4.

C:\Users\aaron\Desktop>java
Enter an integer:13
13 is odd.
13 is neither divisible by 3 nor 4.

C:\Users\aaron\Desktop>java
Enter an integer:132
132 is even.
132 is divisible by 3 and 4.

Question 6. Write a program that collects three Strings from the user. Display the three strings in alphabetical order regardless of the order in which they were input.

Use boolean operators && and/or || in your solution.

(Hint: If you are having a hard time getting this to work with Strings try it with integers first. The logic is the same but the syntax is a bit different.)

C:\Users\aaron\Desktop>java

Please enter three Strings-
John Sally Victor
John
Sally
Victor

C:\Users\aaron\Desktop>java

Please enter three Strings:
John Victor Sally
John
Sally
Victor

C:\Users\aaron\Desktop>java

Please enter three Strings:
Sally John Victor
John
Sally
Victor

C:\Users\aaron\Desktop>java

Please enter three Strings:
Sally Victor John
John
Sally
Victor

C:\Users\aaron\Desktop>java

Please enter three Strings:
Victor John Sally
John
Sally
Victor

C:\Users\aaron\Desktop>java

Please enter three Strings:
Victor Sally John
John
Sally
Victor

Java, Programming

  • Category:- Java
  • Reference No.:- M91410485
  • Price:- $40

Priced at Now at $40, Verified Solution

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 ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

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 ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

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 ...

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 ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

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 ...

  • 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