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
gladu [14]
3 years ago
12

Java code?????

Computers and Technology
1 answer:
12345 [234]3 years ago
5 0

Answer:

Explanation:

Here is the code for you:

import java.io.*;

import java.util.*;

class GirlScoutCookies

{

public static void main(String[] args)

{

int [] BoxesCategory = new int[5];

Scanner sc = new Scanner(System.in);

System.out.print("Total number of girls in the troop: ");

int numOfGirlScouts = sc.nextInt();

for(int i = 0; i < numOfGirlScouts; i++)

{

System.out.print("Boxes of cookies for girl #"+(i+1)+": ");

int boxes = sc.nextInt();

if(boxes >= 0 && boxes <= 10)

BoxesCategory[0]++;

else if(boxes >= 11 && boxes <= 20)

BoxesCategory[1]++;

else if(boxes >= 21 && boxes <= 30)

BoxesCategory[2]++;

else if(boxes >= 31 && boxes <= 40)

BoxesCategory[3]++;

else if(boxes > 40)

BoxesCategory[4]++;

}

System.out.println("TOTAL BOXES\tNUMBER OF GIRL SCOUTS");

System.out.println(" 0 to 10\t"+BoxesCategory[0]);

System.out.println("11 to 20\t"+BoxesCategory[1]);

System.out.println("21 to 30\t"+BoxesCategory[2]);

System.out.println("31 to 40\t"+BoxesCategory[3]);

System.out.println("41 or more\t"+BoxesCategory[4]);

}

}

And the sample output is:

You might be interested in
In which of the following mouse operations do you move the mouse until the pointer is positioned on the item of choice?
wolverine [178]
It's a. You have to move to the item thus pointing ;D
8 0
3 years ago
Develop an algorithm and write a C++ program that finds the number of occurrences of a specified character in the string; make s
nirvana33 [79]

Answer:

The algorithm is as follows:

1. Input sentence

2. Input character

3. Length = len(sentence)

4. count = 0

5. For i = 0 to Length-1

 5.1 If sentence[i] == character

    5.1.1 count++

6. Print count

7. Stop

The program in C++ is as follows:

#include <iostream>

#include <string.h>

using namespace std;

int main(){

char str[100];   char chr;

cin.getline(str, 100);

cin>>chr;

int count = 0;

for (int i=0;i<strlen(str);i++){

 if (str[i] == chr){

  count++;} }

cout << count;

return 0;}

Explanation:

I will provide explanation for the c++ program. The explanation can also be extended to the algorithm

This declares the string and the character

char str[100];   char chr;

This gets input for the string variable

cin.getline(str, 100);

This gets input for the character variable

cin>>chr;

This initializes count to 0

int count = 0;

This iterates through the characters of the string

for (int i=0;i<strlen(str);i++){

If the current character equals the search character, count is incremented by 1

 if (str[i] == chr){  count++;} }

This prints the count

cout << count;

8 0
3 years ago
The following Python statement instructs the program to open a file for input.
Nimfa-mama [501]

The python statement that instructs the program to open a file for input is a false statement.

<h3>How to open file for input ?</h3>

The code above is a python code.

The python statement to instructs a program to open a file for input can be represented as follows:

The Python function open() is a built-in function that opens a file and allows your program to use it and work with it.

The open functions accepts a file(relative path to the file) and a string or character that indicates what you want to do with the file.

inFile = open("grocerydataFinalPY.txt", "w") is use to open a file and write on it.

learn more on python here: brainly.com/question/13696872

#SPJ1

4 0
3 years ago
What occurs along a divergent plate boundary?
den301095 [7]
<span>D- mid- ocean ridges
</span>socratic.org<span>Most active divergent plate boundaries occurbetween oceanic plates and exist as mid-oceanic ridges. Divergent boundaries also form volcanic islands which occur when the plates move apart to produce gaps which molten lava rises to fill</span>
8 0
3 years ago
Read 2 more answers
The period of history before the invention of writing is called
Dmitry_Shevchenko [17]

The period of history before the invention of writing is called unrecorded history.

3 0
3 years ago
Other questions:
  • How can touch typing quickly but accurately improve your earnings (the money you can make)
    15·2 answers
  • Which class of fire extinguisher is appropriate for a fire involving electrical/energized electrical equipment?
    13·2 answers
  • There is a concern to be had about the quality of information found on the internet.
    10·2 answers
  • Write an application that inputs three numbers (integer) from a user. (10 pts) UPLOAD Numbers.java a. display user inputs b. det
    10·1 answer
  • What is the output of the code below assuming that global variable x has value 2 and global y has value 3? def f1(): return "ab"
    13·1 answer
  • Actors,narratirs,and other people whi appear in video programs collectively called what?
    15·1 answer
  • Select the one that uses the heading tag correctly. <br><br>a. <br><br><br>b. <br><br>c. <br><br>d.
    12·2 answers
  • Does the following code return a string or a number def of() return 3
    12·1 answer
  • Within how many days can a deleted view be restored?
    6·1 answer
  • Dawn is trying to find out how much weight she can push across the room. She is really trying to find her __________. A. flexibi
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!