I have to write a program that calculates and displays a person's body mass index (BMI). The BMI is often used to determine whether a person with sedentary lifestyle is overweight or underweight for his or her height. A person's BMI is calaculated with the following formula:
BMI = Weight X 703/Height^2
where weight is measured in pounds and height is measured in inches. The program should display a message indicating whether the person has optimal weight, is underweight, or is overweight. A sedentary person's weight is considered optimal if his or her BMI is between 18.5 and 25. If the BMI is less than 18.5, the person is considered underweight. If the BMI value is greater than 25, the person is considered overweight.However I can't seem to get rid of these errors:
----jGRASP exec: javac BMI.java
BMI.java:28: error: cannot find symbol
Scanner keyboard = new Scanner(System.in);
^
symbol: class Scanner
location: class BMI
BMI.java:28: error: cannot find symbol
I am making a n-body simulation. For some reason, when I have two bodies orbiting each other and I add a third body, the two initial bodies stop orbiting each other.
EXAMPLE:
[URL]- earth is orbiting the sun, when I add mars,[URL] earth AND mars does not orbit the sun and both travel in a straight line. Almost as the forces are not being computed at all on the body. How can this be?
Here is the relevant code:
public void update(float deltaTime){ for(int i=0; i<bodies.size();i++){ resetForces(); bodies.get(i).update((float)(deltaTime / Math.pow(10,9))*timeScale); lastTime = System.nanoTime(); //sets the forces for all bodies for(int n=0; n<bodies.size();n++){
I was asked to write code to calculate a person's calories burned/min. This is what I got. The problem is I keep getting an error.
--------------------Configuration: <Default>-------------------- C:Program FilesJavajdk1.7.0_72CaloriesBurned.java:22: error: possible loss of precision caloriesBurnedPerMinute = 0.0175 * METS * weightInKg; ^ required: int found: double 1 error
Loss of precision? What does that mean? Do I have to change weightInKg into some other number type?
import java.util.Scanner; public class CaloriesBurned { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); int runningHours, basketballHours, sleepingHours, METS, caloriesBurnedPerMinute;
So in my code, I have the user input a number, and the program will then display that element in the array (I've done this bit). However I need to write code to check that the user is entering a valid index number, and if they don't, I need to prompt them that the number they have entered is incorrect and let them retry, and I don't know how to.
This is my full code, I have added a comment underneath where I need to add the code:
import java.util.Arrays; import java.util.Scanner; public class StudentNames { public static void main(String[] args) { String[] names = new String[8]; Scanner s = new Scanner(System.in); for (int i = 0; i < 8; i++) {
I have just taken it upon myself to attempt to develop an application using java that will implement several features for my aircraft maintenance unit. I've taken a few courses in Java and I am a computer science major, so I wanted to use this as a way to improve my coding skills while also improving the effectiveness of my unit.
Anyway my application needs to have these key features:
1. Access a recall roster that is in Excel format and read the names/phone numbers of up to 200 members. The application also needs to be able to update this information and save it.
2. The application also needs to be able to initiate a recall to some or all of the members on the recall roster via text message.
3. The application needs to be able to receive messages back and display them under each name from the recall roster.
My current plan is to set up a GUI that expands JButtons in a scrollable window as members are read in from the excel document. Upon clicking any of the buttons the person will be contacted individually via a custom message that can be typed in via a popup window after clicking it. Alternatively you can check a box next to any persons button to add them to the list of people to be contacted and then click a button that says "Contact those checked" or something along those lines. Finally there will be a button that just says initiate total recall and it will contact everyone.
As for the interface I want each button to be highlighted red until a response has been received from the person associated with that button, which will then be recorded under their contact information.
The pay rate is php 35.00 per hour. any hours worked after 40 hours is paid at rate of 2 times the normal hourly rate. Calculate and display the Normal Pay, The overtime pay, and the total pay.
OUTPUT MUST BE:
Sample 1 :
Enter Hours Worked: 40 (Sample) Normal Pay: 1400 (Sample) Overtime Pay: 0 (Sample) Total Pay: 1400 (Sample)
Sample 2 :
Enter Hours Worked: 41 (Sample) Normal Pay: 1400 (Sample) Overtime Pay: 70 (Sample) Total Pay: 1470 (Sample)
Here is my code or something, but i cant finish it.
import java.util.Scanner; public class Workpay { public static void main(String[]args) { Scanner in = new Scanner (System.in); int hours; int normalpay = 35;
For this program I am calculating the annual costs of 5 office supplies (user input) each with a 5.7% inflation. The user inputs the cost of each object and my program must calculate and display the price of each object each year for 5 years. I already have this part. What I need is how to add the total costs of all 5 supplies per year and display each total cost. Here is the program:
import java.util.Scanner;//Using keyboard to enter data //Start of Class public class OfficeSupplyCalculator { //Start of Method public static void main(String args[]) { Scanner keyboard = new Scanner(System.in); System.out.println("Enter the first item");
[Code] .....
At the moment all I get for the grand total loop is the same number showing up 5 times. I feel like the problem is how I am declaring the grandtotalperyear variable but I'm not sure what is wrong.
I am still new to Java and have an assignment that I am stuck on. I believe I got the boolean function correct, however I cannot figure out what to write in the main function. I have exhausted searching, and trying different loops, arrays, etc.
Alright, so I'm having problems with lines 11 - 55. I'm trying to calculate the possible tiles the clicked unit can be moved on and display it to the player.
The field is a 9 (columns) by 5 (rows) grid. A unit with can move tiles horizontally or vertically based on its movement.
Example: (unit = o; possible tiles = x) (assuming movement of 2).
I tried to calculate movement by finding out what column the unit is in, subtracting the column it wants to go to, multiplying the difference by *-1 if the difference is less than 0. Then, doing the same with rows and adding the difference of columns to the difference of rows and comparing it to the unit's movement. Unfortunately, with my code, it seems to move in any directions.
@Override public void mouseClicked(MouseEvent e) { if (Main.cards.size() > 0) { mainloop: for (int i = 0; i < Main.cards.size(); i++) { Card c = (Card) Main.cards.get(i); int startingColumn = 0;
Write a program that will calculate the cost of a ticket order and display the receipt for the customer on the screen. There are 2 ticket prices: adult, and senior citizen. Adult seats are $4.50 and senior citizen seats are $3.50. If more than 5 senior citizen tickets are purchased, the customer gets an extra 20% off the of the ticket order. If more than 10 regular seats are purchased, the customer gets an additional 10% off the cost of the order. A customer can only place an order for one type of ticket. Output the type of ticket purchased, the number of tickets purchased, the gross cost, the amount of the discount, and the final cost of the order.
I am having errors with incaompatible varriables comparing float with doubles.
public class lab3 { static Library myLib; public static void main (String [] args) { Library myLib = new Library(); //Instance the Library class int ticketNum; //Number of Tickets
I'm trying to create a GUI application that calculates and displays the total cost for certain automotive maintenance services. The application should contain hree classes: 1) the main class that creates and displays the window; 2) a panel for the routine services and 3) a panel for the non-routine services. 2 and 3 are instantiated in 1. I'm pretty positive the error lies in the NonRoutinePanel class because when I comment it out of the main class the program runs fine. But I can't quite figure out which lines of code or methods are causing the problem.
When I try running the program I get these error messages:
Exception in thread "main" java.lang.NullPointerException at java.awt.Container.addImpl(Container.java:1040) at java.awt.Container.add(Container.java:958) at javax.swing.JFrame.addImpl(JFrame.java:540) at java.awt.Container.add(Container.java:926) at JoesAutomotiveGUI.<init>(JoesAutomotiveGUI.java:38) at JoesAutomotiveGUI.main(JoesAutomotiveGUI.java:111)
Here's my code for the three classes:
import javax.swing.*; // Needed for Swing class import java.awt.*; // Needed for BorderLayout class public class RoutineMaintenancePanel extends JPanel { public final double oilChange = 26.00;// cost of oil change public final double lubeJob = 18.00;// cost of lube job
I have a requirement. I got a JSF page(parent page). When a button(say SEND EMAIL) is pressed, an email window (OUTLOOK) will be displayed as a popup. I have to populate whatever the text data of parent page as the body of the mail.
I am using mailto method : eg :
Here is my code: ============== FacesContext context = FacesContext.getCurrentInstance(); HttpServletRequest origRequest = (HttpServletRequest) context.getExternalContext().getRequest(); context.getExternalContext().redirect(String.format("mailto:"+mailTo+"?subject=" + subject +"&body=" + body + "&cc="+mailCc+""));
till here it is fine..
My problem is body part is not getting breaks. I have tried , , , <br>, <br></br> etc.. what ever stuff i found in google..
E.g. my email body looks like below.. it consists of url link also.
I have written sample web application with servlets and jsp. As per the below code the action url should be executed automatically according to the "onload". I have written this below code in one of my servlet, The below "onload" form hits the path in action only in Firefox and IE but not in Chrome(41.0.2272.74 beta-m (64-bit)).I have seen the link [Chrome - <body onload=“”> is not working ][1] , I have my below code in the end of servelt. there is nothing to execute after this code in the servlet.
out.write("<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> "); out.write("<html><body onload="alert('alert has been fired');document.forms[0].submit()"> "); out.write("<form method="POST" action="" + actionUrl + "">
[Code] ....
Is there any reserved key words of chrome in the above action url? If I execute this code in the html format, it is working in chrome. but if it is from servlet, alert() is not running.
I'm struggling with inheritance in my assignment. The assignment states that I should use the calculatePrice() to calculate the total price and use another method to display the total. The I must overload the calculatePrice() and add a fee in the SpeedOrder() class.
My main class
package useorder; import javax.swing.*; public class UseOrder { /** * @param args the command line arguments */ public static void main(String[] args) { Order.display();
[Code] .....
The problem is mainly displaying the TotalPrice field and. I can't display TotalPrice if it's not static but if it's static I can't inherit it to the SpeedOrder class to assign the total in the overloaded calculateprice method. How can I display the total in my order class and use it in my SpeedOrder class?
public class Person implements Comparable<Person> { // the age of the person private int age; //the name of the person private String name; //the Integer object to wrap the age value; private Integer ageWrap;
[Code] .....
The collection library has a class named TreeSet, which is an example of a sorted set. Elements in this set are kept in order. Carefully read the description of this class, and then write a class Person that can be inserted into a TreeSet, which will then sort the Person objects by age.
This is the exercise I am trying to solve. And this is as far as I have gotten to. Is it possible to sort my setOfPersons TreeSet directly? I tried to use
Collections.sort(setOfPersons)
method but it wont compile, and I realized that it is not applicable to TreeSet. So I made the
sortByAge()
method to do it indirectly...
I am puzzled though because in the exercise it states
write a class Person that can be inserted into a TreeSet, which will then sort the Person objects by age.
meaning that the TreeSet will sort the Person Objects and not my class..
I'm supposed to calculate and display the number of total days, and then the number of months, and days from now (when the program is run) to when the person's next birthday is (no leap year). Here is my code:
import java.util.Scanner; import java.text.*; import java.lang.System; import java.util.Date; import java.util.Calendar; public class CSCD210Lab3 { public static void main (String [] args)
[Code] .....
When I call daysFromMillis in the print statement, if I enter in a birthday of 02/17/1993, I will get an answer of "our birthday is 5435 days from now."
User-defined classes. The concept of getters and setters goes right over my head. Right now we're to write a program to test the Person class below. We have to create 2 instances of the class to test each constructor, and test each method.
class Person { // Data Members private String name; // The name of this person private int age; // The age of this person private char gender; // The gender of this person // Default constructor public Person() { this("Not Given", 0, 'U');
[code]....
then my output will print out the name. But the assignment doesn't tell us to modify the Person class at all, just to create a tester one.
How to write a program that will verify the correctness of a person`s birth date in java. The birth date is to be typed in by the user. the program should verify the following: Birth date entered should be of type java.util.Date(), Birth date may not be in future, Age may not exceed 110 years.
The program should copy person with the highest percent from the file 'plik1', and then put it to the file 'plik2'.The problem occurs while compiling.
Java Code: string cannot be resolved to a type string cannot be resolved to a type string cannot be resolved to a type string cannot be resolved to a type string cannot be resolved to a type string cannot be resolved to a type string cannot be resolved to a type string cannot be resolved to a type mh_sh_highlight_all('java'); Code:
Your Tester class main method must use an array or an ArrayList of Person objects. It must be populated from a text data file, friends_data.txt. Add the following data to your text file,
Michelle, 12/20/2008, Camilla Bryan, 3/8/2007, Tom Camilla, 6/7/2005, Michelle Tom, 10/15/2007, Bryan Charlotte, 3/2/2008, Michelle
Each line has the meaning:
-Person name, Person date of birth (MM/DD/YYYY), name of best friend -Write a Java program that reads in the data from the friends_data.txt file, allocates a new -Person for each and then stores the newly created object in either an Array or an ArrayList. -Next print out a report showing the following information for each Person,
1. The Person's name 2. Their popularity counter 3. Their age on May 1, 2014 4. The name of their best friend 5. The age of their best friend on May 1, 2014
Finally, print the name of the most popular Person and the name of the oldest Person.
Person Class
import java.util.ArrayList; public class Person { public String personsName; public String personsFriend; public String personsBirthday; public int personsPopularity; public int popularity = 0;
"method getPopularityNumber in class Person cannot be applied to given type: Required: java.lang.String[]; found: no arguments; reason: actual and formal argument lists differ in length.
1. Does a GET HTTP request contain a request body? If yes what is contained in it? Are the request headers also part of the request body? 2. Is it possible to send a byte array as part of the GET request in its body? 3. Is there a size limitation on the data that can be sent via a GET request?
I'm new to programming and java and I'm trying to understand how exactly this piece of code works and what exactly does. I'm trying to make my first GUI application and to read some person details from a file and then put the result in a Jlist.
private static final String SEPARATOR = ","; public static ArrayList<Speaker> getAllMembers() { ArrayList<Member> members = new ArrayList<Member>(); try { File file = new File(Resources.MEMBERS_TXT); Scanner fileReader = new Scanner(file, "utf-8"); String[] properties;