Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Homework9 {
- public static void main(String[] args) {
- System.out.println("Please choose a type:\n1 --> int\n2 --> double\n3 --> string");
- Scanner scanner = new Scanner(System.in);
- String one = scanner.nextLine();
- if (one.equals("1")) {
- System.out.println("Please enter an integer:");
- } else if (one.equals("2")) {
- System.out.println("Please enter a double:");
- }else if (one.equals("3")) {
- System.out.println("Please enter a string:");
- }
- String two = scanner.nextLine();
- if (one.equals("1")) {
- int input = Integer.parseInt(two);
- System.out.println(++input);
- } else if (one.equals("2")) {
- double input = Double.parseDouble(two);
- System.out.println(++input);
- }else if (one.equals("3")) {
- System.out.printf("%s*", two);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement