Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Procedures for Lab Labs will be run asynchronously during the week that they are assigned for. You are welcome to work with a partner to
Procedures for Lab
Labs will be run asynchronously during the week that they are assigned for. You are welcome to work with a partner to complete the lab. You can have your progress evaluated after any subset of the milestones are completed. The labs are designed to be able to be completed in about an hour. You have until the end of Friday to get all your milestones checked off unless you request an extension The office hours schedule, including locations, is located on Canvas. We suggest you get your milestones checked off as soon as you complete them since Friday office hours tend to become extremely crowded. You will only receive credit for the milestones you have checked off by a TA
Introduction
Welcome to our third week of CSCI This lab will introduce the Scanner class and get you more familiar with how arrays work, as well as giving you more practice on recursive and iterative algorithms.
Find the Maximum Digit in a Number
In this section, you will find the maximum digit in a given positive int both recursively and iteratively. Write a Max class which will have the following methods:
public static int recursiveMaxDigitint num This will find the maximum digit in num recursively
public static int iterativeMaxDigitint num This will find the maximum digit in num iteratively
Add test cases of both methods into your main method.
Hint: Use integer division and the modulo remainder operation to separate out the individual digits. For example, and using Java logic.
Example Test Cases:
recursiveMaxDigit will return
recursiveMaxDigit will return
iterativeMaxDigit will return iterativeMaxDigit will return
CSCI LAB WORKING WITH SCANNER
Milestone :
Show a TA your code for recursiveMaxDigitint and iterativeMaxDigitint and show your test cases running successfully.
Working with Scanner
Over the course of this lab, you may have been slightly bothered by how often you are required to recompile. Every time you change your code, even if its just to slightly change, say, the input to your recursiveMaxDigitint method youll have to recompile. There is however, a better way to do this. We can use the Scanner class.
First off, youll need to import the Scanner class. This is what allows you to use the class in your program. To do this, at the very top of your file, even above the public class Max line, you should add this line:
import java.u
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started