answer.
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
Lelechka
1 month ago
7

Write a loop that reads strings from standard input, where the string is either duck or goose. the loop terminates when goose is

read in. after the loop, your code should print out the number of duck strings that were read.
Computers and Technology
1 answer:
Amiraneli [921]1 month ago
4 0
Consider that the code shown is in C++, however, the same concept can apply no matter the programming language used:

<span><iostream> 
using namespace std; 
int main() 
{ 
int count = 0; 
string input; 
while (true) 
{ 
cout << "Type either goose or duck"; 
cin >> input; 
if (input == "Goose") break; 
count++; 
} 

cout << "Ducks counted = " << count << endl; 
return 0; 
}
</span>
A simpler version can be implemented in Python as follows:
counter = 0 while True: line = input() if line == 'duck': counter += 1 elif line == 'goose': break print(counter)
You might be interested in
Define a new object in variable sculptor that has properties "name" storing "Michelangelo"; "artworks" storing "David", "Moses"
zubka84 [942]

Answer:

String [] artworks = {"David","Moses","Bacchus"};

Sculptor sculptor = new Sculptor("Michaelangelo",artworks,

"March 6, 1475","February 18, 1564");

Explanation:

  • In order to successfully tackle this task;
  • You should create a class (Java is the chosen language) featuring fields for the name, an array of artworks (strings), the date of birth and the date of death.
  • Utilize a constructor to initialize these fields
  • In a separate class SculptorTest, within the main method, generate a String array artworks assigned to {"David","Moses","Bacchus"};
  • Then create a new object of the class using the code provided in the answer section.
  • Refer to the provided code for the complete class definition below:

public class Sculptor {

private String name;

private String [] artworks;

private String bornDate;

private String diedDate;

public Sculptor(String name, String[] artworks, String bornDate, String diedDate) {

this.name = name;

this.artworks = artworks;

this.bornDate = bornDate;

this.diedDate = diedDate;

}

}

//Test Class with a main method

class SculptorTest{

public static void main(String[] args) {

String [] artworks = {"David","Moses","Bacchus"};

Sculptor sculptor = new Sculptor("Michaelangelo",artworks,

"March 6, 1475","February 18, 1564");

}

}

6 0
14 days ago
Here is a super challenge for you if you feel up for it. (You will need to work this out in Excel.) In 2017 the Islamic month of
8_murik_8 [892]

Response:

7/73

Clarification:

May consists of 31 days. By calculating 31 - 26, we find 5 days remaining until June. Therefore, Muslims fasted for a total of 35 days. In 2017, there were 365 days, leading to 365 - 35 = 330 days without fasting. Consequently, the fraction representing the fasting period is 35/365, which simplifies to 7/73.

4 0
29 days ago
A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is the number of steps, and whose output i
ivann1987 [930]

Response:

steps = int(input("Specify the number of steps: "))

miles = steps / 2000

print('{:.2f}'.format(miles))

Explanation:

Prompt the user to input the number of steps and convert the input to an integer.

Compute the corresponding miles by dividing the number of steps by 2000.

Output the miles formatted to two decimal places.

5 0
1 month ago
Explain how abstraction is used in a GPS system
ivann1987 [930]

Answer

Abstraction in GPS technology allows the system to use clearly defined interfaces while enabling the integration of additional, more complex functionalities.

Explanation

The GPS system employs abstraction to organize layers of complexity for user interaction. It connects satellite-based positioning and timing systems to enable a radio receiver to acquire signals across four dimensions—latitude, longitude, altitude, and time—after synchronizing this data.


7 0
1 month ago
Read 2 more answers
Given main(), define the Team class (in file Team.java). For class method getWinPercentage(), the formula is:teamWins / (teamWin
amid [800]

Answer:

Explanation:

public class Team {

   private String teamName;

   private int teamWins;

   private int teamLosses;

   public String getTeamName() {

       return teamName;

   }

   public void setTeamName(String teamName) {

       this.teamName = teamName;

   }

   public int getTeamWins() {

       return teamWins;

   }

   public void setTeamWins(int teamWins) {

       this.teamWins = teamWins;

   }

   public int getTeamLosses() {

       return teamLosses;

   }

   public void setTeamLosses(int teamLosses) {

       this.teamLosses = teamLosses;

   }

   public double getWinPercentage() {

       return teamWins / (double) (teamWins + teamLosses);

   }

}

7 0
13 days ago
Other questions:
  • A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To ac
    11·2 answers
  • . Electricians will sometimes call ______ "disconnects" or a "disconnecting means."
    12·1 answer
  • Describe how the process of sampling, RGB pixels, and binary sequences work together to display a digital color image
    14·1 answer
  •  How does critically analyzing technology add value to interactions with people in personal and professional contexts?
    9·2 answers
  • A company decides to relocate its operations to another state in order to take advantage of some new business investment credits
    15·1 answer
  • How has the development of personal computer hardware and software reversed some of the trends brought on by the industrial revo
    15·1 answer
  • 5.15 LAB: Output values below an amount Write a program that first gets a list of integers from input. The input begins with an
    9·2 answers
  • You work for a car rental agency and want to determine what characteristics are shared among your most loyal customers. To do th
    10·1 answer
  • Which of the following is opened when the Find command is clicked?
    12·1 answer
  • A wireless network was recently installed in a coffee shop and customer mobile devices are not receiving network configuration i
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!