Java multplication table

This program asks for a multiplicand number and shows the multiplication table of given number. MultiplicationTable.java: import java.util.Scanner; public class MultiplicationTable { public void run() { Scanner reader = new Scanner(System.in); int multiplicand; System.out.print(“Which multiplication table would you like to see? “); multiplicand=reader.nextInt(); reader.close(); for(int i=1;i

Java calculator

This program asks for two numbers and the mathematical operator to use on them. Calculator.java: import java.util.Scanner; public class Calculator { public void run() { Scanner numberReader=new Scanner(System.in); Scanner textReader=new Scanner(System.in); double number1, number2; String operator, result, rounding1, rounding2; System.out.print(“Enter first number: “); number1=numberReader.nextDouble(); System.out.print(“Enter second number: “); number2=numberReader.nextDouble(); System.out.print(“Operation: “); operator=textReader.nextLine(); numberReader.close(); textReader.close(); if(operator.equals(“+”))… Read More »

Java min&max

The program asks for three numbers and prints either the biggest or the smallest of them depending which one you choose. BiggestOrSmallestNumber.java: import java.util.Scanner; public class BiggestOrSmallestNumber { public void run() { Scanner numberReader=new Scanner(System.in); Scanner textReader = new Scanner(System.in); int number1, number2, number3; String biggestSmallest; System.out.println(“Enter three numbers:”); number1=numberReader.nextInt(); number2=numberReader.nextInt(); number3=numberReader.nextInt(); System.out.print(“Do you want… Read More »

Java calculate discount

The program asks for a price, checks if it is higher than 1000. If the price is less, it checks if it’s higher than 600 and prints the discounted price or a notification that the price wasn’t high enough. CalculateDiscount.java: import java.util.Scanner; public class CalculateDiscount { public void run() { Scanner reader=new Scanner(System.in); String over6hundred=”8%”,… Read More »

Java address sticker

The program asks for information and prints them out in a address sticker -like form. AddressSticker.java: import java.util.Scanner; public class AddressSticker { public static void main(String[] args) { String name, address, postalCode, city; Scanner input = new Scanner(System.in); System.out.println(“Insert the following data:”); System.out.print(“Full name: “); name=input.nextLine(); System.out.print(“Address: “); address=input.nextLine(); System.out.print(“Postal Code: “); postalCode=input.nextLine(); System.out.print(“City: “);… Read More »