Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class InputReader {
- String str1, str2;
- Scanner scanner;
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- InputReader inreader = new InputReader();
- inreader.printInput();// calls printInput method
- inreader.matchEcho(); //calls matchEcho method
- inreader.printProduct(); //calls printProduct method
- }
- void printInput() {
- System.out.println("Please enter a string");
- scanner = new Scanner (System.in);
- str1 = scanner.next();
- System.out.println("You entered:" + str1);
- }
- void matchEcho() {
- System.out.println("Please enter a string:");
- scanner = new Scanner(System.in);
- str2 = scanner.next();
- if (str2.equals("echo")) {
- System.out.println("Match!");
- }
- else
- System.out.println("Not a match");
- }
- void printProduct() {
- System.out.println("Please enter first int");
- scanner = new Scanner(System.in);
- int int1 = scanner.nextInt();
- System.out.println("Please enter second int");
- int int2 = scanner.nextInt();
- int product = int1*int2;
- System.out.println("The product is:" + product);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement