How to write a java class which multiply long numbers? The class will receive multiplicand and multiplier as string input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to write a java class which multiply long numbers? The class will receive multiplicand and multiplier as string input

27th Mar 2017, 1:45 AM
laiba malick
laiba malick - avatar
3 Answers
+ 3
in this first read the value from user.In java user valus are in string format then convert it from string to int by using Integer.parseInt wrapper clases and then print its product
27th Mar 2017, 4:29 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 2
import util.scanner.*; class Sample { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int multiplicant = Integer.parseInt(sc.nextInt); int multiplier = Integer.parseInt(sc.nextInt); int product = multiplicant * multiplier; System.out.println(" product is:" +product); } }
27th Mar 2017, 4:24 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 2
oh thank you!
27th Mar 2017, 6:12 AM
laiba malick
laiba malick - avatar