Created
March 5, 2015 06:12
-
-
Save yoxisem544/632074e7ee4f8ba0f9e1 to your computer and use it in GitHub Desktop.
HW1 - java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Scanner; | |
| public class Hey { | |
| public static void main(String[] args) { | |
| System.out.println("Subtotal and gratuity rate: "); | |
| double a, b; | |
| int c; | |
| float g; | |
| Scanner scanner = new Scanner(System.in); | |
| a = scanner.nextInt() * 1.0; | |
| b = scanner.nextInt() * 1.0; | |
| System.out.println("The gratuity is $" +a*b/100 + " and total is $" + (a+b/10)); | |
| System.out.println("Enter on digit between 1~1000"); | |
| while(true) { | |
| scanner = new Scanner(System.in); | |
| c = scanner.nextInt(); | |
| if (c > 1 && c < 1000) { | |
| break; | |
| } | |
| System.out.println("wrong rang, again!"); | |
| } | |
| a = 1; | |
| while(c != 0) { | |
| a *= c%10; | |
| c /= 10; | |
| } | |
| System.out.println(a); | |
| System.out.println("Enter the number of minutes:"); | |
| scanner = new Scanner(System.in); | |
| a = scanner.nextInt() * 1.0; | |
| b = a/60/24; // days | |
| System.out.println(Math.floor(b/365)+" years, " + b%365+ "days."); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment