A multiplication problem is provided as a string using the f
Solution
Multiplication.java
import java.util.Scanner;
public class Multiplication {
public static void main(String[] args) {
//Declaring variables
int x,y,multResult;
String input;
//Scanner object is used to get the inputs entered by the user
Scanner sc=new Scanner(System.in);
//Getting the input string entered by the user
System.out.print(\"Enter input :\");
input=sc.nextLine();
//Getting the value of x from the input string
x=Integer.parseInt(input.substring(0,input.indexOf(\' \')));
//Getting the value of y from the input string
y=Integer.parseInt(input.substring(input.lastIndexOf(\' \')+1,input.length()));
//Performing multiplication and stored into the variable multiResult
multResult=x*y;
//Displaying the output
System.out.println(x+ \" * \"+y+\" is \"+multResult);
}
}
________________
Output:
Enter input :4 times 3
4 * 3 is 12
__________Thank You
