Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do this problem using two integers with either 3, or 4, or 5-digit. The two numbers might not have the same digits length. Please use

Do this problem using two integers with either 3, or 4, or 5-digit. The two numbers might not have the same digits length. Please use only one single loop with one System.out.printf statement for printing the shifted multiplicands as shown in the example below. Please name the class name as PrintMultipOfNDigits.

image text in transcribed

import java.util.*; public class PrintMultipOfNDigits{ public static void main(String[] args){ Scanner in = new Scanner(System.in); System.out.println("what's first (3~5)digits :"); int firstnum = in.nextInt(); //set first digit System.out.println("what's second (3~5)digits :"); int secondnum = in.nextInt(); //set second digit int l1= (secondnum%10)*firstnum; //getting first line by module 10 and times first digit so like first digit time last second digit. int l2= ((secondnum%100)/10)*firstnum;//getting second line by module 100 and divide by 10 and then time first digit time 10. int l3= ((secondnum%1000)/100)*firstnum;// getting third line by module 1000 and divide by 100 and then time first digit time 100. int l4= ((secondnum%10000)/1000)*firstnum; int l5= ((secondnum%100000)/10000)*firstnum; int answer = l1+l2+l3+l4+l5; System.out.printf(" %d * %d -------------- %d %d %d %d %d -------------- %d ",firstnum,secondnum,l1,l2,l3,l4,l5,answer); }

}

I am having trouble with this problem help me please. this is code i got until now.

5903multiplicand 178 multiplier 47224 shifted multiplicands 413210 +590300 1050734 product

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions