import java.util.Scanner;
public class SophiaKeyProgram1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int numQuarter; //number of quarters in a year
double rainfall=0; //the amount of rain
I have written program for rainfall that will store and give total, average, least and most. The program stores the input of rainfall for each month. However at the end it suppose to print out the month with the least and most rainfall. I am getting this on the print for
The month with the most rainfall: [Ljava.lang.String;@79a7bd3b
and for
The month with the least rainfall: [D@7378aae2[Ljava.lang.String;@79a7bd3b
Write a program that stores the total rainfall for each of the 12 months into an array of doubles. The program should have methods that return the following:
The total rainfall for the year The average monthly rainfall The month with the most rain The month with the least rain
"Create a project called RainFall and a class nameD RainFall. Write a program that stores the total rainfall for each of 12 months into an array of doubles. The program should display total rainfall for the year, the average monthly rainfall, the month with the most rain and the month with the least rain. When outputting the month with the most and least rain, output the name of the month. This is what I have so far.
how does the program know to calculate for only one year?
public class Interest2 { public static void main(String[] args) { double principal; // The value of the investment. double rate; // The annual interest rate. double interest; // The interest earned during the year.
I have spent the past 12 hours on it and have gotten no where. I need to create a program that will calculate different tax brackets. I have tried all combinations I can think of and can't get it to work!!! I am literally about to go insane! I need the program to calculate tax will be 1% for anything up to $50000. If the tax is over $50000, you keep that 1% of $50000 and then add the remaining. So for an income in the second range, it would be 1% of $50000, and then 2% of (income - $50000). This then continues for each range.
The problem I'm having is getting it to display the correct interest rates. I am not asking for you to write it for me. I want to learn. But at this point I have exhausted all resources available to me.
import java.util.Scanner; public class Project3taxinfo { public static void main(String[] args) { final double RATE1 = 0.01; //1% tax on the first $50,000 final double RATE2 = 0.02; //2% tax on the amount over $50,000 up to $75,000 final double RATE3 = 0.03; //3% tax on the amount over $75,000 up to $100,000 final double RATE4 = 0.04; //4% tax on the amount over $100,000 up to $250,000 final double RATE5 = 0.05; //5% tax on the amount over $250,000 up to $500,000 final double RATE6 = 0.06; //6% tax on the amount over $500,000
I'm starting with my version of very basic program: calculating area of circle. And of course it doesn't get well. My question: what is wrong in this code?
public class circleAre{ double radious; void putData(double radi){ radi = radious;
I am having a problem with my program. I can't get my program to calculate properly. Everything compiles and run but its just giving me a wrong answer. I am suposse to get 115.50 but instead I am getting .30...
order.java public class Order { double salesTaxRate; //initializing a variable for the sales tax rate. double subTotal; //initializing a varliable for the sub total. double shippingCost; //initializing a variable for shipping cost. double salesTax; //initializing a variable for sales tax. double totalCost; // initializing a variable for totale cost.
Assume the tanker is a cylinder of length 19.35 feet and volume 1320 gallons. What is the diameter in feet of the tanker truck? To solve this problem, write a Java program to calculate the diameter. For full credit, your Java application must follow these specifications.
1. The program must interactively input the capacity of the tanker in gallons and its length in feet. This should be done in the main method of your Tester class.
2. The input data should then be used to construct a TankerTruck object. You will need to write the TankerTruck class.
3. A TankerTruck method should be used by main to calculate the resulting diameter of the truck in feet.
4. Your program should use the standard Java constant for the math constant PI.
5. The output should be displayed using fixed-point notation, rounding to one decimal place of precision
Write method distance, which calculates the distance between two points (x1, y1) and (x2, y2). All numbers and returned values should be of type double. Incorporate this method into an program that enable the user to enter the coordinates of the points, then calculate and display the distance by calling the method –distance.
I've tried numerous times to make it work and I'm on the right path, however I'm missing some things in the code to make my results look like this later on, which I've attached onto this post.
write a program that calculates the change due to a customer by denomination; that is, how many pennies, nickels, dimes, etc. are needed in change. The input is to be purchase price and the size of the bill tendered by the customer($100, $50, $20, $10, $5, $1).
having some trouble doing this. Here are the requirements:
1)Write a program using loop and break to calculate the value of PI. 2)You can use the following equation to calculate PI. PI=4/1-4/3+4/5-4/7+4/9-4/11+4/13 etc.. The program shouldn't loop until the criteria is satisfied. 3)The criteria is the value of PI you get is very close to the “real” value (3.1415926), meaning that their difference should be smaller than a very small numeric number, e.g., 0.0001). 4)The control structures you may need for this program are loop, if-else, and unlabeled break. 5)The output should have the format: for each iteration, it has iteration number and the corresponding value of PI until that iteration. The last line would be the final value of PI.
Here is my code so far:
package ids; public class IDS { public static void main(String[] args) { double pi = 0; for(int i=1; i<=100000; i++){ if ((i%2)==0){ pi+=(4/(2*i-1));
I have to use methods and loops to code this program. Cannot use any java set or any built in java shortcuts!
import java.util.Scanner; public class setPractice { public static Scanner kbd; public static final int MAXSIZE = 20; public static void main(String[] args) { kbd = new Scanner(System.in);
[Code] .....
This is the input I put in my code and this is the output:
How many numbers will be in the 1st set: 3
Enter list of integers for 1st set: 34 2 56
The ascending order for 1st is: 2 34 56
How many numbers will be in the 2nd set: 4
Enter list of integers for 2nd set: 56 2 33 6
The ascending order for the 2nd set is: 2 6 33 56
The intersection of the two sets is: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
I want to Write a program that calculates the minimum fixed monthly payment needed in order pay off a credit card balance.
the Amount is 3,500 the annual rate is 9.9%, the minimum payment is 2% a month. the fixed payment is 150.
By a fixed monthly payment, we mean a single number which does not change each month, but instead is a constant amount that will be paid each month.
The program should print out :
payment information: new balance total ....... current payment due .......
if you make minimum payment (2%) you will pay of in .... months and you Will end up paying an estimated total of $........
if you make the fixed rate payment, you will pay of in .... months and you Will end up paying an estimated total of $........ and you will save $........
I am making a gradebook program that calculates the averages of 25 students using 2D arrays in which the students have four test grades. I have figured out how to display the averages of each student in one column but I cant seem to figure out how to display the letter grade of the average into another column.
Right now my program reads from a .txt doc
Heres what I've got.
TestGradeBook.java
import java.util.*; import java.io.*; public class TestGradeBook { public static void main (String [] args ) throws IOException{ //Declarations final int ROWS = 100; final int TESTS = 4;
[Code] .....
GradeBook_Data.txt Name100100100100 // basic name and grades
You are to write a parallel program that will receive a large array of unsorted integers containing digits from 0 to 99. The program will have to calculate the SUM and AVERAGE of ODD number digits between 25 and 75 (inclusive). The user may specify the size or the array and the total processor that the machine has. The size of the array must be divisible by number of processor. Based on the given size, the computer will generate random integer numbers automatically to populate the array.
The program should display the status of the calculation for each processor. The result should be displayed after all calculations are completed.Error messages should be displayed appropriately
a) Write a sequential (non-parallel) program that will accomplish above task. b) Write a concurrent (parallel) program that will produce the result of the above task.
I just created a program to calculate the roots for a 2. degree equation, When I first created my program, I defined the r1 and r2 as double, but got an error saying they needed to be defined as String, why is that?When should I be using string? I am new to java and I have mostly only used int, double and Boolean so far.
import java.util.Scanner; import java.text.DecimalFormat; public class c3e1 { public static void main(String[]args){
So I've attempted a for loop for this type of problem:If you receive $0.01 on the first day of your allowance, and the daily rate doubles each day after, calculate the total earnings for 30 days.
Output should be like: Day ----- Daily allowance - Total allowance 1 -------- 0.01 -------------- 0.01 2 -------- 0.02 -------------- 0.03 3 -------- 0.04 -------------- 0.07
My code so far:
public class Allowance { public static void main (String[] args) { int day = 0; double daily = 0.0; double total = 0.1; System.out.println("Day Daily Allowance Total Allowance"); for(day = 0; day <= 30; )
I have understood my programming class up to this point and now I have been given a lab that I can't figure out for the life of me. Here what I have to do: Write a program that will call a method (called f) to calculate the following function" f(x)=(x^2)-16...this is what the output should be:
Write a program to calculate the telephone charges for four customers. The data for each customer consists of NAME, PREVIOUS METER READING, PRESENT METER READING. The difference between the two readings gives the number of units used by the customer for the period under consideration.
The amount due for each customer is calculated by: UNITS USED * RATE PER UNIT + RENTAL CHARGE The rate per unit and rental charge is assumed to be the same for all customers and must be input once only.
Your program must:
a. Input the rate and rental charge b. Read the data for each customer and calculate the amount due c. Print the information under suitable headings d. Calculate and print the total amount due to the telephone company
I am assigned with a project that will as the user for the amount of days they would like data entered, then loop asking them for these numbers. once it reaches the entered amount of days it will display a menu for which the user can enter the number they want on the list and it will display the data. the menu has 6 items. Total, Average, Determine if its a Drought, Flood or normal rainfall, highest of data entered, lowest of data entered, and 6 is to quit the program.
So far i have total and average working properly. Still looking at how to display drought, flood, and normal.
Main problems, i cannot get highest and lowest to display correct data.
Also when entering 6, or an invalid menu choice, neither "goodbye" or "invalid choice, choose again" gets printed. Rather the loop for entering data continues.
import java.util.Scanner; public class RainAnalysis { /* * Project 1 This program will analyze the rainfall for the number of days a user inputs. */
public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); int numOfDays = 0; double rainfallAmount = 0.0;
[Code] ....
Here is a sample output to show what happens when i put in 6 after the menu is displayed.
also i noticed that it does not say the correct day when displaying the lowest and highest rainfall. this is because i put count, i did not know what else to put in order to get the correct day.
how many days do you want to monitor rainfall?5
Enter the rainfall for day 1.01 Enter the rainfall for day 2.1 Enter the rainfall for day 36 Enter the rainfall for day 43 Enter the rainfall for day 51
Rainfall Data Display Menu: 1 - Display total rainfall. 2 - Display rain average for the period. 3 - Display if drought, flood, or normal conditions. 4 - Display the day and amount of the highest rainfall. 5 - Display the day and amount of the lowest rainfall. 6 - Quit the program.
Enter your choice: 4 Day5 has the highest rainfall with 6.0 inches.
Rainfall Data Display Menu: 1 - Display total rainfall. 2 - Display rain average for the period. 3 - Display if drought, flood, or normal conditions. 4 - Display the day and amount of the highest rainfall. 5 - Display the day and amount of the lowest rainfall. 6 - Quit the program.
Enter your choice: 5 Day5 has the lowest rainfall with 0.1 inches.
Rainfall Data Display Menu: 1 - Display total rainfall. 2 - Display rain average for the period. 3 - Display if drought, flood, or normal conditions. 4 - Display the day and amount of the highest rainfall. 5 - Display the day and amount of the lowest rainfall. 6 - Quit the program.
I'm trying to print out the results of a program that calculates the number of seats the parties will get in an election.I have to print the partial results and the national results.
I can print te number of seats per party in each constituency, but how can i sum all seats per party in each constituency and print the national results?I'm working with vectors, which I know it might not be the best option, but everything is working, except the fact that I can't loop throuhg the vector and retrieve the total sum per party.Like, adding the seats for labour party in Constituency A and B and C, etc, and print the sum. And do the same for conservative party.Is it possible, or doIhave to create a method in Parties class to solve the problem?
This is what I have now.
for (Parties p : h.geral) { show += String.format("Constituency - %5s - %5s - %d%n", p.getConstituency(), p.getParty(), p.getNum_seats()); }