1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
liraira [26]
3 years ago
6

Code a program that will go through all the numbers from 1 to 100 and print them. However, if the number is evenly divisible by

3 then print the word "fizz" instead of the number. If the number is evenly divisible by 5 then print the word "buzz" instead of the number. And, if the number is evenly divisible by both 3 and 5, print the word "fizz buzz" instead of the number. Use a loop, and use modulus division. Only the driver class is needed, and in main just call 1 method called fizzBuzz().
In java.
Computers and Technology
1 answer:
worty [1.4K]3 years ago
8 0

Answer:

public class Main

{

   // required method

   public static void fizzBuzz(){

       // looping through 1 to 100

       for(int i = 1; i <= 100; i++){

           //if number is evenly divisible by both 3 and 5

           if(i%3 == 0 && i%5 == 0){

               System.out.println("fiz buzz");

           }

                   // if number is divisible by 3

           else if (i%3 == 0){

               System.out.println("fizz");

           }

                        // if number is divisible by 5

           else if (i%5 == 0){

               System.out.println("buzz");

           }

                       // if number is not divisible by both 3 and 5

           else {

               System.out.println(i);

           }

       }

   }

       // main method

       public static void main(String[] args) {

           //calling function

               fizzBuzz();

       }

}

Explanation:

You might be interested in
Write an overloaded constructor for the Table class that will take a single argument for the color of the table Write a set meth
creativ13 [48]

Explanation:

Below is required code in java :-

public class Table{

   private String color;    //attribute to store the color of the table

   public Table(){    //default constructor

       this.color="";   //set a default blank color

   }

   public Table(String color){    //overloaded constructor

       this.color=color;    //set the color value equal to the parameter provided

   }

   public void setColor(String color){    //setter or mutator method

       this.color=color;    //set the color value equal to the parameter provided

   }

}

8 0
4 years ago
Which is NOT a reason to study science?
VMariaS [17]
Hi!

Science is a way of thinking about the natural world. It asks thought provoking questions and investigates deep into the human mind, our Earth, our periodic table, or our cosmos.

It's a vast field, with a myriad of career options. Scientists want to learn more about how our natural world works, and experiment to discover newfound facts about life as we know it.

Not to <em>blow... </em>away... your... expectations... but, in science, we rarely blow up things. If you're interested in seeing explosions, go apply to be a myth buster.

Hopefully, this helps! =)
8 0
4 years ago
Write a C++ program that creates a map containing course numbers and the room numbers of the rooms where the courses meet. The d
swat32

Answer:

Program approach:-

  • Using the necessary header file.
  • Using the standard namespace I/O.
  • Define the integer main function.
  • Mapping course numbers and room numbers.

Explanation:

//header file

#include<iostream>

#include<map>

//using namespace

using namespace std;

//main function

int main(){

               //creating 3 required maps

               map <string,int> rooms;

               map <string,string> instructors;

               map <string,string> times;

               //mapping course numbers and room numbers

               rooms.insert(pair<string,int>("CS101",3004));

               rooms.insert(pair<string,int>("CS102",4501));

               //mapping course numbers and instructor names

               instructors.insert(pair<string,string>("CS101","Haynes"));

               instructors.insert(pair<string,string>("CS102","Alvarado"));

               //mapping course numbers and meeting times

               times.insert(pair<string,string>("CS101","8:00am"));

               times.insert(pair<string,string>("CS102","9:00am"));

               

               char choice='y';

               //looping until user wishes to quit

               while(choice=='y' || choice=='Y'){

                               cout<<"Enter a course number: ";

                               string course;

                               cin>>course;//getting course number

                               //searching in maps for the required course number will return

                               //an iterator

                               map<string, int>::iterator it1=rooms.find(course);

                               map<string, string>::iterator it2=instructors.find(course);

                               map<string, string>::iterator it3=times.find(course);

               

                               if(it1!=rooms.end()){

                                               //found

                                               cout<<"Room: "<<it1->second<<endl;

                               }else{

                                               //not found

                                               cout<<"Not found"<<endl;

                               }

               

                               if(it2!=instructors.end()){

                                               cout<<"Instructor: "<<it2->second<<endl;

                               }

               

                               if(it3!=times.end()){

                                               cout<<"Meeting Time: "<<it3->second<<endl;

                               }

                               //prompting again

                               cout<<"\nDo you want to search again? (y/n): ";

                               cin>>choice;

               }

7 0
3 years ago
Please answer the following essay question:
MArishka [77]
Advertising is a paid promotion that uses strategic planning to target a certain audience. The seven functions of marketing is promotion, selling, product management, marketing information management, pricing, financing, and distribution. Usually you see common advertising such as digital ads, billboards, newspapers, flyers, and more. Advertising can spread awareness, popularize a brand, increase customer demand, and company profits. Advertising is necessary for most- if not all- companies including media outlets, the television industry, search engine companies, and social media websites.
8 0
3 years ago
U.S. cybersecurity experts and government officials are increasingly concerned about breaches from __________ into corporate net
Triss [41]

Answer:

Organized crime syndicates based in the United State

Explanation:

U.S. cybersecurity experts and government officials are increasingly concerned about breaches from organized crime syndicate based in the United States into corporate networks, either through mobile devices or by other means.

The crime syndicate can go to any length to access corporate network through mobile device or any other means in order to commit crimes that is why the US cyber security expert and government officials are increasingly concerned.

Cyber security specialists or expert in the US are been employed to protect information or data that the crime syndicate may want to gain access to by using different variety of techniques by critically monitoring the systems network for attempted breaches by the crime syndicates and then dealing with any of them that is found guilty.

5 0
3 years ago
Other questions:
  • How to find the biggest files on your computer?
    10·1 answer
  • Every time you are asked to work with others, you are being asked to:
    6·2 answers
  • Membrane-bound organelles are not found in the cells of A) bacteria. B) fungi. C) plants. Eliminate D) protists.
    15·2 answers
  • What is a society that has moved to the internet Rather than relying on physical media called
    11·1 answer
  • Which of the following represents the TCP/IP four-layer reference model? Group of answer choices Application, Internet, transpor
    11·1 answer
  • Eric is working on a computer that has a device driver error. Eric can find the name of the device driver however the actual dev
    13·2 answers
  • Right-of-way is __________. A. guaranteed by Florida law B. the privilege of immediate use of the road C. earned by aggressive d
    15·1 answer
  • What is wrong with a MOV BL, CX instruction?
    6·1 answer
  • Select the correct answer
    15·1 answer
  • What is it called when you define a variable for the first time
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!