Write a program that collects three strings

Assignment Help JAVA Programming
Reference no: EM13840670

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

Reference no: EM13840670

Questions Cloud

Calculate the present value of an investment : Calculate the present value of an investment whose cash flow would pay $5000 per year, to be paid out at the end of each year for three years, and where 1. that cash flow is projected to grow by an expected 6% per year in years two and and three.
Purchase a mercedes benz roadster : Q. 1 (Total Marks: 13)Timothy Smith is looking to purchase a Mercedes Benz Roadster, whichhas a total cost of $340,000. Timothy plans to deposit $130,000 and willpay the rest by taking on a 7.5% 5-year loan. Required: a) What is the monthly payment o..
What you think is meant by the blue wall of silence : Describe what you think is meant by the blue wall of silence? Does it truly exist or is this just a perception? Would a police officer with very strong morals, values, and ethics fail to expose officer wrongdoing? Does the subculture constrain the..
Firm a and firm b have debt-total asset ratios : Firm A and Firm B have debt-total asset ratios of 41% and 31% and returns on total assets of 8% and 13%, respectively.  What is the return on equity for Firm A and Firm B?
Write a program that collects three strings : 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.
Collaboration in a business environment : Collaboration in a business environment
Define what a fraud : What a Fraud
The role of the environment in process of crime causation : Research will be conducted on the topic, the role of the environment in the process of crime causation to find out what are the environmental factors, which influence social behavior of a person leading to the specific individual to perceive certa..
Department of justice requires prosecutors to consider : Identify and explain some of the factors that the Department of Justice requires prosecutors to consider when charging an organization. What benefits do organizations get from following these factors and the Federal Sentencing Guidelines?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Loops-for loop, while loop, and do while loop

There are 3 kinds of loops-for loop, while loop, and do while loop. Under which circumstances would each kind of loop be more appropriate

  Determine the type of moped

Write a driver class called MopedRental. This class should perform the following: asks the user to enter the size of the moped, the day of the week and the number of hours rented, creates the Moped object, based on the size, and displays the input..

  Typical industrial engineering problem

A company manufactures two products, A and B. Product A can be sold for $145 per unit and B for $75 per unit. Management requires that at least 1850 units be manufactured each month.

  Design a java program that has two parallel arrays

Design a java program that has two parallel arrays: a string array named people that is initialized with the names of seven of your friends, and a string array named phoneNumbers that is initialized with your friends phone numbers.

  Development of a simple menu driven program

Identify all of the lines of code within the program that are associated with obtaining user input. This can be done by either copying the lines into your answers or highlighting the lines within the code.

  Write a method called range that returns the range of value

Write a method called 'range' that returns the range of values in an array of integers. The range is defined as 1 more than the difference between the maximum and minimum values in the array. For example, if an array called list contains the value..

  Create a java class called watertank

Create a Java class called WaterTank.java. This program will simulate thedraining of a cylindrical water catchment tank. Your program will need to show how the rate at which water would exit the tank, assuming an output nozzle two inches (2") in d..

  Create the investment calculator

Create the following GUI that allows a user to calculate the value of an investment after a certain number of years with monthly compound interest.

  Reading in strings from a text file into an array

If I am reading in strings from a text file into an array, where do I place this file at so that CodeBlocks will find it?

  Discuss the legal ramifications of the division of condo

Discuss the legal ramifications of the division of condo, BioTech and other assets. Would it make any difference if Violet sold the property after filing for the dissolution of marriage?

  Java program that prompts the user to input three numbers

Need a java program that prompts the user to input three numbers. This program should then output the numbers in nondescending order

  Write a program that displays a drawing popular hangman game

Write a program that displays a drawing for the popular hangman game, as shown in Figure 15.32(c). draws a sketch for the hangman game.

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