6.4.. Napisati program za izračunavanje količnika i ostatka pri dijeljenju 7 sa 2 ( DIV i MOD)
Opis rješenja:
Opis programa:
Listing programa:
package zadatak;
import java.util.Scanner;
public class P06412016 {
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.println("7 DIV 2=" + 7/2);
System.out.println("7 MOD 2=" + 7%2);
System.out.println("-7 DIV -2=" + -7/-2);
System.out.println("-7 MOD -2=" + -7%-2);
System.out.println("-7 MOD (-2)=" + -7%(-2));
System.out.println("-7 DIV 2=" + -7/2);
System.out.println("-7 MOD 2=" + -7%2);
System.out.println("7 DIV -2=" + 7/-2);
System.out.println("7 MOD -2=" + 7%-2);
System.out.println("7 MOD (-2)=" + 7%(-2));
}}
Ispis na ekranu:
Index
|