Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How do I make it so I can add decimals to the amount and quantity and also recieve a correct decimal
How do I make it so I can add decimals to the amount and quantity and also recieve a correct decimal [message #1007677] Wed, 06 February 2013 21:52 Go to next message
Joseph Charles is currently offline Joseph Charles
Messages: 1
Registered: February 2013
Junior Member
import java.util.Scanner;

public class Percentage {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

final double percent = 100;
System.out.println("How much does the item cost: ");
double Amount = input.nextInt();
System.out.println("Insert the quantity of the object: ");
double quantity = input.nextInt();
double x = Amount * percent / quantity;

System.out.println("Cost per ounce is " + x);


}

}
Re: How do I make it so I can add decimals to the amount and quantity and also recieve a correct dec [message #1007840 is a reply to message #1007677] Thu, 07 February 2013 12:20 Go to previous message
Christian Dietrich is currently online Christian Dietrich
Messages: 6145
Registered: July 2009
Senior Member
Hi,

i am not sure how this is related to xtext?

~Christian
Previous Topic:Kepler TypeNotFoundException
Next Topic:Syntactic predicates in 0.8M4
Goto Forum:
  


Current Time: Sat Aug 02 04:51:56 EDT 2014

Powered by FUDForum. Page generated in 0.01922 seconds