Question

Write a perl program that prompts a user for a number and checks that number against...

Write a perl program that prompts a user for a number and checks that number against three possibilities. If the number is divisible by 3, it should print fizz, if its divisible by 5 it should print buzz, and if its divisible by 3 and 5 it should print fizzbuzz. It should do nothing if none of those conditions are met.

I need help with this.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#!/usr/bin/perl6
# your code goes here
use strict;
use warnings;
my $i = <STDIN>;
if ( $i % 3 == 0 && $i % 5 == 0 ) { print 'fizzbuzz' }
elsif ( $i % 3 == 0 ) { print 'fizz' }
elsif ( $i % 5 == 0 ) { print 'buzz' }
print "\n";

Add a comment
Know the answer?
Add Answer to:
Write a perl program that prompts a user for a number and checks that number against...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MULIMI Umplicated than the hrst assignment. Write a program that will let the user enter an...

    MULIMI Umplicated than the hrst assignment. Write a program that will let the user enter an integer. If the integer is less than 5 make the actual input value be 50. We will call the value that the user put in N. Print the integers from 1 to None number on each line. If the number you are going to print is divisible by 3 print the word fuzz instead of the number. If the number is divisible by 5...

  • Write a program that prompts the user to enter an integer and checks whether the number...

    Write a program that prompts the user to enter an integer and checks whether the number is divisible by both 5 and 6, divisible by 5 or 6, or just one of them (but not both). SAMPLE OUTPUT Enter an integer: 10 Is 10 divisible by 5 and 6? False Is 10 divisible by 5 or 6? True Is 10 divisible by 5 or 6, but not both? True (Python programming language)

  • (1) Read in a number from the user that is in the ranger 1-200. If the...

    (1) Read in a number from the user that is in the ranger 1-200. If the user inputs a number out of that range, print out:Invalid number, try again. and read in a number until a valid one is produced. (2) Print out the numbers from 1 to userInput but: If a number is divisible by 3, print Fizz instead If a number is divisible by 5, print Buzz instead If a number is divisible by both 3 and 5,...

  • C++ Write a program that prompts the user to enter two positive integers: num1 and num2....

    C++ Write a program that prompts the user to enter two positive integers: num1 and num2. - Validate that num1 is less than num2 and that both numbers are positive. If any of these conditions are not met, allow the user to re-enter num1 and num2 until the input is determined valid. - For all integers from num1 through num2, print the word keyboard if the current integer is divisible by 2 and print the word mouse if the current...

  • Python: Using your favorite text editor, write a program that outputs the string representation of numbers...

    Python: Using your favorite text editor, write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”. Submit by uploading a .py file Example: n = 15, Return: [ "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz"...

  • LANGUAGE C++ I need help with all 3 questions. Thank you in advance Password Generator← 10...

    LANGUAGE C++ I need help with all 3 questions. Thank you in advance Password Generator← 10 10.201.51. eRAD D scheduling山UitPro 6 Fizz Buzz Write a function "void FizzBuzz(int n)" that lists all of the numbers from 1 to n, but replace all numbers divisible by 3 but not divizible by 5 with the word "Fizz", replace all numbers divisible by 5 but not divisible by 3 with the word "Buzz", and replace all numbers divisible by both 3 and 5...

  • Write a C program that prints the numbers from 1 to 100, but substitutes the word...

    Write a C program that prints the numbers from 1 to 100, but substitutes the word “fizz” if the number is evenly divisble by 3, and “buzz” if the number is divisible by 5, and if divisible by both prints “fizz buzz” like this: 1 2 fizz 4 buzz fizz 7 8 fizz buzz 11 fizz 13 14 fizz buzz 16 17 fizz 19 buzz ... and so on

  • C++ Write a program that prompts the user to enter integers or a sentinel to stop....

    C++ Write a program that prompts the user to enter integers or a sentinel to stop. The program prints the highest and lowest numbers entered, the sum and the average. DO NOT USE ARRAYS, only variables and loops. Write a program the prompts the user to input a positive integer. Keep asking the user until a positive integer is entered. Once a positive integer is entered, print a message if the integer is prime or not. (NOTE: A number is...

  • Write a C program that prints the numbers from 1 to 100. But for multiples of...

    Write a C program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

  • Python Create a function for the Fizz Buzz program (see Assignment01, Q11). The function takes the...

    Python Create a function for the Fizz Buzz program (see Assignment01, Q11). The function takes the following 3 arguments with default values: 1) max_iteration=100 2) fizz_divider=3 3) buzz_divider=5 The function iterates numbers from 1 to max_iteration any number divisible by fizz_divider, “print fizz” Any number divisible by buzz_divider, “print buzz” Any number divisible by fizz_divider and buzz_divider, print “fizz buzz” Otherwise, print the number

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT