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] Thu, 07 February 2013 02:52 Go to next message
Joseph Charles is currently offline Joseph CharlesFriend
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 17:20 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6552
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: Mon Dec 22 23:32:11 GMT 2014

Powered by FUDForum. Page generated in 0.01926 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software