Witam!
Mam problem ze stworzeniem programu.
Zrobiłem menu wyboru ale kompletnie nie wiem co dalej.
Program ma: 1. Sumować n wartość podanych przez uzytkownika. Liczby naturalne.
2. Obliczać różnicę wartości podanych przez użytkownik liczb. 3. Wyjście z programu.
Mam problem w zaimplementowaiu tej n oraz zrobieniu obliczeń.
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package ag_petle; import java.util.Scanner; /** * * @author admin */ public class AG_Petle { public int Menu(Scanner z1){ int wybor=0; System.out.println("Menu\n"); System.out.print("1. Suma\n"); System.out.print("2. Roznica\n"); System.out.print("3. Wyjscie\n"); Scanner sc = new Scanner(System.in); wybor=sc.nextInt(); return wybor; } public static void main(String[] args) { AG_Petle zm = new AG_Petle(); Scanner sc = new Scanner(System.in); float wynik=0, a=0; System.out.print("Podaj wartosc dla a: "); a=sc.nextFloat(); switch (zm.Menu(sc)) { case 1: { wynik+=a; System.out.println(a+=a); break; } case 2: { } default: System.out.println("Brak zdefinioowanej operacji"); } } }