This question has already been answered:
Good day! Just started to learn JAVA, more precisely a new subject in Uni building informatics. So I got the first house. work
The bottom line is, you need to enter the variable int z = 5; then z divided by two and the answer is saved as a variable containing a real number (I assume this double ), but the answer still costs 2.0 instead of 2,5 . The task is to find a solution to this problem and bring the answer to the right and right kind. I really hope for your help!
package anwendung; public class Project { public static void main(String[] args) { // TODO Auto-generated method stub // Aufgabe_1 // lokale Variablen int a = 5; int b = 23; //Berecnung von a+b System.out.println("a + b = " +(a + b)); //Berechnung b%a System.out.println("b % a= " + (a % b)); //Berechnung b/a System.out.println("b / a = " + (b/a)); //Berechnung a++ System.out.println("a++ = " + (a++)); //Berechnung b-- System.out.println("a * b = " + (a*b)); // Berechnung a+ System.out.println("a+ = b = " + (a+=b)); //Berechnung a*b++ System.out.println("a * b ++ = " + (a*b++)); //Berechnung a<=b System.out.println("a < + b =" + (a<=b)); //Berechnung a>b System.out.println("a > b =" + (a>b)); //Berechnung System.out.println("a == b =" + (a==b)); //Berechnung a!=b System.out.println("a ! = b =" + (a!=b)); //Aufgabe_2 //Aufgabe_3 //Neue Variable int c = 2147483647; System.out.println(" c + 1 = " + (c + 1)); // Variable "c" ist um 1 erhöht und Wert ist jetzt negativ, /* Wenn durch eine Operation der Wertebereich über- oder unterschritten wird, Programmiersprachen reagieren so dass, dass bei derAddition der Zahl 1 auf die größte positive Zahl des Wertebereichs die kleinste negative Zahl des Wertebereichs alsErgebnis ausrechnen */ //Aufgabe_4 int z = 5; double p = z / 2; System.out.println(p); } }
double p = z / 2.0;- Alexey Shimansky