Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please i need a java code You should have the user (you, in this case) type out a Binary number within the VPL window like

Please i need a java code image text in transcribed
image text in transcribed
You should have the user (you, in this case) type out a Binary number within the VPL window like this... You'll have to use the Scanner class to get input from the user. Scanner allows you to specify if the entry should be treated as a String or as an integer, etc. When the user is expected to enter an Integer (as is the case here), use the nextint() method. For example: scanner.nextint(). This is different than the nextLine() method. There's a wrinkle in this problem. You are to assume that the integer that is being entered is in Binary form. That means that if the user enters 10 they don't mean "ten". They mean "two". To do this, you have to modity the scanner object to use a different "radix". This is also known as a base. A regular number has a radix of 10 . We often call these 'decimal" numbers or "base 10 numbers because we count in groups of ten. A binary number has a radix of 2 because you count in groups of two: 0 then 1 . How do you do this? Use the radixi) mathod. What does a binary number look like? 0 is 0.1 is 1 . The number 2 ? It's 10 . And three? it's 11. Seven is 111. Eight is 1000 . What to reproduce this on your own machine? Here are some important files: - preb.abCigava (student template) - MyTest.java (Junit test file) [You can "run" this exercise but cannot "evaluate" it. Therefore, there is no auto grade. Simply get it running and manually select it as complete] Requested files preLabC.java 1/ Step 1. Add in a line here to accept o nen Scanner object. if You're done this before... vor ... sonething sonething... Scanner(System. in); ... // what goes here? II Step 2. Tell Jave that the thing you're going to scan in witl be in Btnary forn (only 1 's and a's) II ObjectNane oor useRadix( SovE , Maner ) : If what number should you use in the parentheses? 2 for Binary. ... 1/ the scanned object should be in binary (Radix 2) I/ Step 3. Scan the vatues fron the user. It's going to return an integer, not a String: Integer binaryinteger - seannedobject.nextIntO );// capture the user entry as an Integer object. System. outiprintlin("In this black VPL box, enter a binary nurber: ") Systen, out.printlnc" "You entered " binaryInteger *", ahich in binary is ", integer, fobinarystringlbina return binaryinteger

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

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

Identify the nine clusters in the analytics ecosystem.

Answered: 1 week ago

Question

Recognize the four core purposes service environments fulfill.

Answered: 1 week ago