Explanation of Solution
Program:
File name: “Population.java”
//Define a class named Population
public class Population
{
//Define main method
public static void main(String[] args)
{
//Declare variables and initialize the values
//set growth rate in percent
double RATE_OF_GROWTH_OF_MEXICO=0.0101;
//set decay rate in percent
double RATE_OF_DECAY_OF_USA=0.0015;
//set years
int years=1;
//Set Mexico population as 128 million
double mexicoPopulation=128000000;
//Set USA population as 323 million
double usaPopulation=323000000;
//Print the result
System.out.printf("%-10s%-20s%-15s\n","Years","Mexico","USA");
/*While condition that checks if the Mexico
population is less than USA population */
while (mexicoPopulation<usaPopulation)
{
//Print the result
System...
Trending nowThis is a popular solution!
Chapter 6 Solutions
Java Programming, Loose-leaf Version
- Please help me with the question on the picturearrow_forwardHelp me with this java program please.arrow_forwardUse Java programming language Write a program that asks the user to enter 5 test grades (use an array to store them). Output the grades entered, the lowest and highest grade, the average grade, how many grades are above the average and how many are below and the letter grade for the average grade. Create a method that returns the lowest grade. Create a method that returns the highest grade. Create a method that returns the average grade. Create a method that returns how many grades were above the average. Create a method that returns how many grades were below the average. Create a method that returns the letter grade of the average (90-100 – A, 80-89 – B, 70-79 – C, < 70 – F)arrow_forward
- Write a Java GUI program Create a program using GUI format where you are to enter 12 monthly sales (in array) of ABC Enterprises for the year 2022. The program would then output the following: a. Total sales for the year b. Quarterly sales and their subtotal c. Semi-annual subtotalsarrow_forwardFirst, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects). Then create a new Java application called "RecursiveTriangle" (without the quotation marks) according to the following guidelines. Modify the example below so that the triangle displays “in reverse order”, which allows the user to set the number of lines to print and the String used for printing the triangle. public static void printTriangle(int sideLength) { // quits if sidelength is at 0 or smaller if (sideLength < 1) { return; } // recursion - method is calling itself printTriangle(sideLength - 1); // main loop that prints out the body of the triangle for (int i = 0; i < sideLength; i ++) { System.out.println("[]"); } System.out.println();} Use a method to prompt the user for the number of lines (between 1 and 10) to print. This method should take no parameters and return an int value. Use a method to prompt the user for the string to be used…arrow_forwardI want to develop an application for Knight's Tour Chess Game in java where the board is an eight by eight - 2D array board. Each square should be 0 in the beginning and as the knight moves in L shaped moves. The application is developed to move the knight around the chessboard and then keep a counter that varies from 1 to 64. Record the latest count in each square the knight moves to. Test each potential move to see if the knight has already visited that square. Test every potential move to ensure that the knight does not land off the chessboard. I want to run the application with random initial position.arrow_forward
- Write an Java application that prompts the user for a checking account balance and a savings account balance (The balance of these two account should be generated automatically by the program within this range 1 to 100 rand and stored into an array ). Display the message “Checking account balance is low” if the checking account balance is less than R10. Display the message “Savings account balance is low” if the savings account balance is less than R100. Save the file as Balance.java. 1. Use of a random function- 2. use of an array to store the generated balance - 3. use of an if statement 4 . Display of correct outputarrow_forwardWrite an application that displays a series of at least five student ID numbers (that you have stored in an array) and asks the user to enter a numeric test score for the student. Create a ScoreException class, and throw a ScoreException for the class if the user does not enter a valid score (less than or equal to 100). Catch the ScoreException and then display an appropriate message. In addition, store a 0 for the student’s score. At the end of the application, display all the student IDs and scores. Save the files as ScoreException.java and TestScore.java.arrow_forwardIn JAVA. Any and all help is appreciated, please also show the results with your code. Please see the attached image.arrow_forward
- Java Program : Imagine that you own your own retail store and you need to display a menu of all the item categories, items and prices you sell for your customers. Come up with any 3 or more categories that you would sell in your store. Come up with any 4 or more products for each category. Display the prices for each product and category. The list of products and the list of prices should be stores in 2 separate arrays. Create a method "display" that accepts 2 arrays as parameters and displays the product and the prices in receipt form. Create another method "sum" that displays the total for each category.arrow_forwardA customer in a store is purchasing three items. Write a JavaFx application that asks for the price of each item, tax %, and whether item will be picked up or delivered; Then display the subtotal of the sale, the amount of sales tax, and the total, if items are to be delivered, add fee to the total cost.your program should at least 4 methods: 1. A method to get the price of item and return as double array. 2. A method that receives the price array and tax % as parameters, calculates the sales tax, and returns the sales tax. 3. A method that receives the total price, sales tax, and delivery fee as parameters, and displays all along with the subtotal. 4. A main method where the above are called appropriately to solve the problem.arrow_forwardThis code is in java.You are walking along a hiking trail. On this hiking trail, there is elevation marker at every kilometer. The elevation information is represented in an array of integers. For example, if the elevation array is [100, 50, 20, 30, 50, 40], that means at kilometer 0, the elevation is 100 meters; at kilometer 1, the elevation is 50 meters; at kilometer 2, the elevation is 20 meters; at kilometer 3, the elevation is 30 meters; at kilometer 4, the elevation is 50 meters; at kilometer 5, the elevation is 40 meters. b) Write a method called longestUphill that returns the elevation change in meters of the longest uphill section. In the example above, the method should return 30 because the longest uphill section is from kilometer 2 with 20 meters to kilometer 4 with 50 meters. The elevation change is 50 - 20 = 30 meters. Note: A flat section with no elevation change is not considered part of an uphill.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT