Calculate Shipping Charges Based On Product Weight In Pounds And Distance In Miles

Mar 26, 2014

I want to write a Utility to calculate the shipping charges based on the product weight in pounds and distance in miles. How we can go about it.

View Replies


ADVERTISEMENT

Stored Function - Calculate Delivery Charges Given City And Weight

May 27, 2014

A stored function to calculate delivery charges given city and weight.
 
CREATE OR REPLACE FUNCTION CALCULATE_CHARGES
(
CITY IN VARCHAR2
, CHARGES IN NUMBER
, TOTAL IN NUMBER
) RETURN NUMBER AS
BEGIN
RETURN total:=city*charges;
END CALCULATE_CHARGES;

View Replies View Related

Find Distance Between One Point To Another Using Miles And Feet?

Sep 19, 2014

Pretty much what im trying to accomplish, i need to write a program that figures out the distance between one point to another, using miles and feet..

Heres how it has to look: "The distance from my uncles house is ___ miles, or ____ feet."

I can get it to run if i add only whole miles..but when i try to add 8.5 miles, and compile, the program flips out..I know i need to use a double somewhere, but cant figure it out, here is my code..

import java.util.Scanner; //required for input
public class feetToMiles {
public static void main (String[] args){
//Create new scanner object called input
Scanner input = new Scanner (System.in); //allows for input

[Code] ....

View Replies View Related

Write A Program To Calculate Telephone Charges For Four Customers

Apr 13, 2014

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

************************************
java.jpg
************************************

I just need the totalX in my for loop to print the total but the total i want to print it is in the while loop

View Replies View Related

Method From Main - Calculate Weight On Different Planets

Nov 8, 2014

I have to write a program to calculate my weight on different planets and to do that, I have to read in the surface gravity of all the planets from a file using a separate method from main

public static double[] readGravity() throws IOException
{
double[] surfaceGravity = new double[8];
Scanner readFile = new Scanner("gravity1.txt");
int i = 0;
while (readFile.hasNext()) {
surfaceGravity[i] = readFile.nextDouble();
i++;
}
return surfaceGravity;
}

I get this message in the while loop when I try to run the program:

java.util.InputMismatchException;
null (in java.util.Scanner)

View Replies View Related

How To Use For Loop To Calculate Product Of Consecutive Numbers

Feb 26, 2015

I wanted to know if I was off to the right start. I am trying to write a program using the for loop the calculate the product of the consecutive numbers 4 through 8 but so for I am getting 3 values output and I only want 1 value at the print out.

The code I am using outputs the numbers too large. I am trying to see where I went wrong.

for ( int i = 4 ; i <= 8; i++)
{
int j = i++;
int k = j++;
int l = k++;
int m = l++;
System.out.println( + (i*j*k*l*m) );
}

View Replies View Related

Java Program Method To Calculate Distance

Feb 20, 2015

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.

View Replies View Related

Calculate Distance From Starting Point Of Any Shape

Mar 13, 2015

I need to modify the drawShape method to calculate the distance from the starting point (the diameter) of any shape regardless of how many sides I give it, but I have absolutely no clue where to begin with this. The ultimate goal of the program is to calculate the value of pi using the shape that is drawn.

Here is the code:

public class PiTurtle extends Turtle
{
private double mySize;
private int mySides;
private double diameter = 0; 
final static double startX = 590.0;
final double startY;
public PiTurtle(int nSides)

[Code] .....

View Replies View Related

Modify DrawShape Method To Calculate Distance From Starting Point

Mar 13, 2015

I need to modify the drawShape method to calculate the distance from the starting point (the diameter) of any shape regardless of how many sides I give it, but I have absolutely no clue where to begin with this. The ultimate goal of the program is to calculate the value of pi using the shape that is drawn.

Java Code:

public class PiTurtle extends Turtle
{
private double mySize;
private int mySides;
private double diameter = 0;

[code]....

View Replies View Related

Calculate Distance Between Two Coordinates And Determine How Much Of Which Axis To Increment / Decrement

Feb 1, 2015

Basically I'm looking for a way to make one object follow another. For example, if I move object A to one area of the screen I want object B to to move to object A's location but I also want object B to move at a fixed speed (movement variable). How do I go about doing this?

Both the x and y coordinates of object B would need to know the coordinates of object A to calculate the distance between the two and to determine how much of which axis to increment/decrement (if that makes sense?) with the inclusion of the speed variable. In other words I'm just trying to create a homing object.

View Replies View Related

Loop That Calculate Distance Traveled - Why Java Not Printing Method Results

Apr 13, 2014

I am trying to write a loop that calculates the distance traveled (distance = speed * time). It should use the loop to calc how far the vehicle traveled for each hour of time. My program asks for hours and then mph but its not calculating time * speed. Here is my code.

public static void main(String[] args) {
 Scanner input = new Scanner(System.in);
System.out.println("Enter Hours Traveled ");
int hoursTraveled = input.nextInt();
System.out.println("Enter MPH ");
int mph = input.nextInt();
 
[Code] .....

View Replies View Related

Calculate Distance Between Two Points - All Numbers And Return Values Should Be Of Type Double

Jul 8, 2014

Write method distance to calculate the distance between two points (x1, y1) and (x2, y2). All numbers and return values should be of type double. Incorporate this method into an application that enables the user to enter the coordinates of the points.

Hints:

- The distance between two points can be calculated by taking the square root of

( x2 - x1 )2 + ( y2 - y1 )2

- Use Math class methods to compute the distance.

- Your output should appear as follows:

Type the end-of-file indicator to terminate

On UNIX/Linux/Mac OS X type <ctrl> d then press Enter

On Windows type <ctrl> z then press Enter

Or Enter X1: 1

Enter Y1: 1

Enter X2: 4

Enter Y2: 5

Distance is 5.000000

Type the end-of-file indicator to terminate

On UNIX/Linux/Mac OS X type <ctrl> d then press Enter

On Windows type <ctrl> z then press Enter

Or Enter X1: ^Z

View Replies View Related

Method Parameters - Two Fields Of Type Double / Calculate Distance To Another Point

Oct 18, 2014

I've just been having a go at an exercise where I have to create and use a class called Point, with two fields of type double. I have to create some methods for it, one of which is a distanceTo(Point) method, that calculates the distance to another point. I've tried to keep the distanceTo(Point) method short so have created some other methods to use within the method. My question is about the getDistance() method that I've made. As you can see below, I've given it two parameters, which are references to values within two Point objects (this.x and otherPoint.x).

double distanceTo(Point otherPoint) {
double distanceX = getDistance(this.x, otherPoint.x);
double distanceY = getDistance(this.y, otherPoint.y);
return calculateLength(distanceX, distanceY);
}

View Replies View Related

Tax Return - Constructor Calculate Tax Liability Based On Annual Income And Percentage

May 12, 2014

With fields that holds a tax payer social security number, last name, first name, street address, city zip code, annual income, marital status and tax liability, include a constructor that requires argument that provide values for all other fields other than the tax liability. the constructor calculates the tax liability based on annual income and percentage in the ff table

Income
0-20,000
20,000-50,000
50,000 and over

marital status
single married
15% 14%
22% 20%
30% 28%

View Replies View Related

Calculate Cost To Fill A Pool Based On Its Shape / Length / Width And Depth

Sep 17, 2014

This program is for a swimming pool filling service company. They charge 2 cents per gallon and $50 per hour to fill a pool. The truck can fill at a rate of 730 gallons per hour.

Create the Pool class that calculates the cost to fill a pool based on it's Shape, length, width and depth. (Input order is S L W D)

The pool class will need data fields for String shape, double length, double width, double depth, static double GallonsPerSqFoot = 7.4805, static double price per gallon = .02, static double FillingFeePerHour = 50.0, and static double FillingRate = 730gal/hr.

Create a No-Arg constructor and a constructor that accepts the non-static values, and has the methods: getShape, getLength, getWidth, getDepth, getGallons, getHours, getFillingFeePerHour, getHourlyCost and getTotalCost.

At the end of the class, create a main() method that asks for the input and returns the output based on the Pool class gets.. methods.

The shape options are oblong or rectangle. (A round pool would be oblong with the same width and height, a square pool would have the same width and height)

Formulas:
Rectangle cubic ft = length * width * depth.
Oblong cubic ft= ((Math.PI * Math.pow(width/2,2)* depth) +((length-width) * width * depth))
Gallons = cubic ft * 7.4805.
hours = total gallons/730.
Total cost = (total Gallons * .02)+(hours * $50)

Example Output
An oblong pool 18.00 feet long by 12.00 feet wide and 5.00 feet deep will use 6923.10 gallons of water and take 9.48 hours to fill. The total cost will be 612.65.

Here is my code:

import java.util.Scanner;
import java.util.*;
public class Pool
{
private String poolshape1 = "oblong";
private String poolshape1 = "rectangle";
private double length;
private double width;
private double depth;
private static double GallonsPerSqFoot = 7.4805;

[Code] .....

View Replies View Related

Calculate Tax Payments Based On Income And Filing Status - Handling Input Mismatch Exception

Nov 27, 2014

I have written the following code to calculate tax payments based on income and filing status :

import java.util.Scanner;
public class computeTax {
    public static void main(String[] args) {   
        Scanner input = new Scanner(System.in);
        // prompt for filing status
        System.out.println("enter '0' for single filer,");

[Code] ....

The while loop initiated on line 21 is there so that in case the wrong input is given at the prompt given in line 24, the program outputs "please type the right answer" with the command on line 254 before looping back to line 24 and prompting the user to enter his status number.  The program works as long as the input at line 28 is an integer.  Not surprisingly if the erroneous input here is not an integer, the program outputs the following error message :
 
Exception in thread "main" java.util.InputMismatchException
    at java.util.Scanner.throwFor(Scanner.java:909)
    at java.util.Scanner.next(Scanner.java:1530)
    at java.util.Scanner.nextInt(Scanner.java:2160)
    at java.util.Scanner.nextInt(Scanner.java:2119)
    at computeTax.main(computeTax.java:28

To try to solve this I used the Try / Catch technique with the following version of the code : 

import java.util.Scanner;
public class computeTax {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        // prompt for filing status       
        System.out.println("enter '0' for single filer,");

[Code] ....

View Replies View Related

Convert Kilograms To Pounds With Dialog Box

Jan 17, 2015

I have managed to write the program where the user can input kg and the formula converts it into lbs. I have also written a program where I can get a dialog box to appear to ask the user to input the kg, but I can't figure out how to combine the two.

This program allows the user to input the kg, it converts it to lbs and then displays the output:

import java.util.Scanner;
import javax.swing.JOptionPane;
//creates a dialog box
 
public class convert {
public static void main(String args[]) {
 
[Code] ....

This program only brings in the first variable and the initial dialog box:

import java.util.Scanner;
import javax.swing.JOptionPane;
 //creates a dialog box
public class KgLbs {
public static void main(String args[]) {
 
[Code] ...

I have attached the actual assignment and what the program should look like.

View Replies View Related

How To Add Shipping Address During CheckOut Process

Apr 21, 2014

I'm Fresher and i'm new in ATG nd right now working on checkout module.Here I'm trying to take shipping information of user so it is fetching in the shipping information JSP bt when i'm trying to submit that JSP den it's not going to either in SuccessURL or in ErrorURL it's remaining in current JSP.

I'm doing any customization's i'm jst using al Out Of Box Components nd my code is almost same as Out Of Box Code and it is not giving any error also.

I'm attaching my JSP's

Attached File(s)

shipping_jsp.txt (4.17K)
Number of downloads: 293
 shippingAddress_jsp.txt (1.9K)
Number of downloads: 135
 shippingSingle_jsp.txt (70bytes)
Number of downloads: 19
 shippingSingleForm_jsp.txt (2.05K)
Number of downloads: 102

View Replies View Related

Calculate Tax Payable Based On Income And Income After Tax Deduction

Nov 3, 2014

I'm writing some code which calculates the tax payable based on income, and I need to have a separate method which then calculates the income AFTER the tax has been deducted. I've done this quite easily by re-writing the code in the next method, however is there a more efficient way around this where I can pass the values from the first method to do the calculation...

public class TaxCalculator {
// Main method calling taxpayablereturn and taxafterdeduction
public static void main(String[] args) {
System.out.print("Tax Payable = £"
+ TaxCalculator.taxpayablereturn(570));
 
[Code] ......

View Replies View Related

Program To Find Miles Per Gallon

Jan 23, 2015

I have to write a program the calculates the MPG and display's the result on the screen. However, I have three errors I just can't seem to figure out. jGrasp points to the following error, but doesn't tell me what it is:

Programming Challenge #9.java:34: error: cannot find symbol
gallons = keyboard.nextInt();
^
symbol: variable keyboard
location: class MPG
3 errors
 
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

My code is as follows:

import java.util.Scanner;
 /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
 
// This program has variable of several of the integer types.
 public class MPG {
public static void main(String[] args) {

[Code] ....

View Replies View Related

Program For Weight Conversion GUI

Apr 21, 2015

I'm working on a Weight Conversion program. The code I have for the program is:

import java.util.*;
import java.awt.*;
import javax.swing.*;
public class Frame4a implements ActionListener {
public static void main(String[] args) {
JFrame f = new JFrame("Weight converter");
JPanel P = new JPanel(); // Make a JPanel;

[Code] .....

The errors I'm getting are:

Frame4a.java:33: error: class, interface, or enum expected
public void actionPerformed(ActionEvent e){
^
Frame4a.java:37: error: class, interface, or enum expected
double kp= Double.parseDouble(strkilo);

[Code] .....

View Replies View Related

Output Error About Converter (Miles / Kilometer)

Nov 28, 2014

I'm doing to create miles/kilometers converter. If I put the mile, converting to kilometer is right. However, if I put the kilometer, converting to mile comes out wrong value. Which part is wrong?

import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;

[Code] .....

View Replies View Related

Write A Program That Display Miles And Kilo

Apr 21, 2014

1. Write a program that displays the following table (note that 1 mile is 1.609 kilometer):

Miles Kilometers
1 1.609
2 3.218
3 4.827
...
...
9 14.481
10 16.090

Note: use for loop and printf() to format your output

public class MilesandKilometers {
public static void main(String[] args) {
System.out.println("Miles Kilometers");
int miles = 1
;
for (int i = 1; i <= 10; miles++, i++) {
System.out.println(miles + " " + miles * 1.609);
}
}
}

how to make it like the instruction said " use for loop and printf() to format your output".

View Replies View Related

Two Weight In Kilograms And Grams - Print Sum

Oct 22, 2014

Write a program which request two weight in kilograms and grams and print the sum of the weight, if the weight are 3kg 500g and 4kg 700g, your program should print 8kg 200g. this is what i have

Scanner input = new Scanner (System.in);
double weight, kg, g;
int sum;
System.out.println("Please enter weight");
weight = input.nextDouble();

[Code] .....

View Replies View Related

User Input In Miles And It Is Supposed To Multiply With Feet

Sep 21, 2014

I have a program where the user enters in the miles and then it is supposed to get multiplied by feet but I keep getting this error.

GetUserInfo.java:12: error: bad operand types for binary operator '*'
int total = name * feet;
^
first type: String
second type: int

1 error

This is my code so far :

import java.util.Scanner;
public class GetUserInfo
{
public static void main(String[] args) {
String name;
int miles;

[Code] ....

View Replies View Related

Input Weight In Kilograms And Grams And Print Sum

Oct 23, 2014

write a program which request two weight in kilograms and grams and print the sum of the weight, if the weight are 3kg 500g and 4kg 700g, the program should print 8kg 200. this is what I have so far and there is an error that I can't see:

Scanner input = new Scanner (System.in);
double weight, kg, grams;
int sum;
System.out.println("Please enter weight");
weight = input.nextDouble();

[Code] ....

um = (3kg5oog + 4kg700g)-(this line here is where the error is, it supposed to sum the two statement and print out 8kg 200g but i keep getting the red line, dont know where the error is, dont know if it is the coding or what, where error is, where the coding is not right, I am totally lost here right now, this is the if statement.

if(weight )

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved