Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(java) Have the function StringChallenge( num ) take the num parameter being passed and return all the numbers from 1 to num separated by spaces,

(java) Have the function StringChallenge(num) take the num parameter being passed and return all the numbers from 1 to num separated by spaces, but replace every number that is divisible by 3 with the word "Fizz", replace every number that is divisible by 5 with the word "Buzz", and every number that is divisible by both 3 and 5 with the word "FizzBuzz".

For example: if num is 16, then your program should return the string "1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16". The input will be within the range 1 - 50.

PLEASE IMPLEMENT SOLUTION INTO THIS STARTER CODE & keep the function call , console log the answer

import java.util.*;

import java.io.*;

class Main {

public static int StringChallenge(int num) {

// code goes here

return num;

}

public static void main (String[] args) {

// keep this function call here

Scanner s = new Scanner(System.in);

System.out.print(StringChallenge(s.nextLine()));

}

}

Examples

Input: 3 Output: 1 2 Fizz

Input: 8 Output: 1 2 Fizz 4 Buzz Fizz 7 8

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

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions