Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.java > #9291

perchè mi restituisce un intero?

From Pino <utr1utr@gmail.com>
Newsgroups it.comp.java
Subject perchè mi restituisce un intero?
Date 2019-06-02 00:48 +0200
Organization Aioe.org NNTP Server
Message-ID <qcuvcq$u82$1@gioia.aioe.org> (permalink)

Show all headers | View raw


Nel codice seguente,se assegno 10 e 3 ai due interi, la divisione mi 
restituisce 3.0  anzichè  3.333333

Come mai?

grazie


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

			System.out.print("primo numero? ");
		int n1 = input.nextInt();
		

		System.out.print("secondo numero? ");
	int n2 = input.nextInt();
	
	double divisione =  n1/n2;
	System.out.print("disione :" + divisione );
	
	input.close();
}
}

Back to it.comp.java | Previous | NextNext in thread | Find similar


Thread

perchè mi restituisce un intero? Pino <utr1utr@gmail.com> - 2019-06-02 00:48 +0200
  Re: perchè mi restituisce un intero? "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2019-06-02 01:18 +0200
    Re: perchè mi restituisce un intero? Pino <utr1utr@gmail.com> - 2019-06-02 15:06 +0200

csiph-web