Kurs:Java (Kjell)/Code-Rubrik/Bestellung Schrauben.java

Bestellung Schrauben.java

Programmcode Bearbeiten

package kapitel_12;

import java.io.*;

class Bestellung_Schrauben {


	public static void main(String[] args) throws IOException {

		BufferedReader stdin = 
	    	 new BufferedReader ( new InputStreamReader (System.in));
		
		// V a r i a b l e n   d e k l a  r i e r e n
		
		String inData;
		final int Schraubenpreis        = 5,
		          Mutterpreis           = 3,
		          Unterlegscheibenpreis = 1;
		
		int schrauben, muttern, unterlegscheiben; //Anzahl
		
		// E i n g a b e n   a b w i c k e l n
		
		System.out.println("Anzahl der Schrauben:");
		inData           = stdin.readLine ( );
		schrauben        = Integer.parseInt(inData);
		
		System.out.println("Anzahl der Muttern:");
		inData           = stdin.readLine ( );
		muttern          = Integer.parseInt(inData);		
		
		System.out.println("Anzahl der Unterlegscheiben:");
		inData           = stdin.readLine ( );
		unterlegscheiben = Integer.parseInt(inData);
		
		// K o n t r o l l a b s c h n i t t  
 		
		if (schrauben > muttern) {
			
			System.out.println("Kontrollieren Sie Ihre Bestellung!");
			
		}
		else {
			
			System.out.println("Die Bestellung ist okay.");

		}
		
		// B e r e c h n u n g   d u r c h f ü h r e n
		
		
		System.out.println("Gesamtbetrag: " + ( schrauben * Schraubenpreis
				+ muttern * Mutterpreis
				+ unterlegscheiben * Unterlegscheibenpreis)
				);
	}

}