• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

performing long multiplications using string

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I got this question on the entrance exam for MCS ,can someone tell me how it's solved or provide code for it please , I have a feeling it will be helpful for the next exam.Thanks

Write a java class that multiplies the long number. The class will receive multiplicand and multiplier as string inputs, convert string values to their digit represent and show the partial products and product as shown in the example below:

adsdasd.png
[Thumbnail for adsdasd.png]
 
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the ranch Farhan.

Farhan Karim wrote:can someone tell me how it's solved or provide code for it please



That isn't how it works here. How about you provide your attempt at a solution and ask us specific questions about things you don't understand, and we'll help you from there.

Start by writing down the steps you would take when solving that problem manually.
 
Saloon Keeper
Posts: 14498
325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Fahran, welcome to CodeRanch!

We don't hand out complete solutions here. Instead, we can help you solve the problem by yourself.

Write a class that has a method that splits the multiplier into single digits. Then, you can multiply the multiplicand with a multiplier digit times 10 to the power of the digit's position to get the partial product.
 
Marshal
Posts: 76856
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome again

Hope it's not too late, but in addition to the helpful advice you have already received:-
Write down carefully on paper how you do “long” multiplication by hand. Things like, “put the rightmost digit under the digit being multiplied and pack with 0s,” are what you want. When you have such an explanation on paper, it is much easier to turn into code.
 
permaculture is giving a gift to your future self. After reading this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic