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
Contact [7]
3 years ago
7

Write a method called classSplit that accepts a file scanner as input. The data in the file represents a series of names and gra

duation years. You can assume that the graduation years are from 2021 to 2024.Sample input file:Hannah 2021 Cara 2022 Sarah2022Nate 2023 Bob 2022 Josef 2021 Emma 2022Your method should count the number of names per graduation year and print out a report like this --- watch the rounding!:students in class of 2021: 28.57%students in class of 2022: 57.14%students in class of 2023: 14.29%students in class of 2024: 00.00%You must match the output exactly.You may not use any arrays, arrayLists, or other datastructures in solving this problem. You may not use contains(), startsWith(), endsWith(), split() or related functions. Token-based processing, please.There is no return value.
Computers and Technology
1 answer:
Lelu [443]3 years ago
4 0

Answer:

public static void classSplit(Scanner file){

   int studentsOf21 = 0, studentsOf22 = 0,studentsOf23 = 0, studentsOf24 = 0;

   while (file.hasNext() == true){

       String studentName = file.next();

       int year = file.nextInt();

       switch (year){

           case 2021:

               studentsOf21++;

               break;

           case 2022:

               studentsOf22++;

               break;

           case 2023:

               studentsOf23++;

               break;

           case 2024:

               studentsOf24++;

               break;

       }

   }

   int totalGraduate = studentsOf21+studentsOf22+studentsOf23+studentsOf24;

   System.out.printf("students in class of 2021: %.2f%n", students2021*100.0/totalGraduate);

   System.out.printf("students in class of 2022: %.2f%n", students2022*100.0/totalGraduate);

   System.out.printf("students in class of 2023: %.2f%n", students2023*100.0/totalGraduate);  

   System.out.printf("students in class of 2024: %.2f%n", students2024*100.0/totalGraduate);

}

Explanation:

The classSplit method of the java class accepts a scanner object, split the object by iterating over it to get the text (for names of students) and integer numbers (for graduation year). It does not need a return statement to ask it prints out the percentage of graduates from 2021 to 2024.

You might be interested in
If an element is nested within another element, what happens to each line of the nested element?
Elden [556K]

Nested elements are elements that are placed within another element.

When an element is nested within another, all lines of the nested element will <em>inherit </em>the <em>properties </em>of the parent element.

Take for instance, the following HTML code

<em><p align = "center"> I am a <b>boy</b> </p></em>

In the above HTML code,

The bold element (i.e. <b>) is nested in the paragraph element (i.e. <p>)

The paragraph element is aligned center.

This means that, all elements in the paragraph element (including the <em>bold element</em>) will be centralized.

Hence, all lines of a nested element will <em>inherit </em>the properties of the parent element.

Read more about nested elements at:

brainly.com/question/22914599

7 0
3 years ago
Jiz<br>Active<br>2<br>3<br>- 2(7 - 15)<br>What is the value of<br>4​
-Dominant- [34]

Answer: I think it is c

Explanation: hope this helps

3 0
3 years ago
Read 2 more answers
Write a function insert that takes an array of integers in ascending order, the number of integers currently in the array, the t
Andrei [34K]

Answer:

The code is written in MATLAB

function insert(array,integer,capacity,newInt)

if integer == capacity %if the array is full, the function returns the original array

result = array;

else

if newInt < array(1) %If the new integer is less than the first element, it copies the new integer as the new first element

array = [newInt array];

elseif newInt > array(end) %If the integer is greater than the last element, it copies the new integer as the new last element

array = [array newInt];

else %If the new integer is inside the array, then it checks its new place

for i = 1:length(array)-1

if array(i+1) > newInt % once the place of the new integer is found, the rest of the array is saved in a dummy array

dummy = array(i+1:end);

array(i+1) = newInt;

array(i+2:end) = '';%the rest of the array is deleted

array = [array dummy]; %concatanate the dummy array with the newInteger inserted array

break

end

end

end

end

fprintf('The inserted integer is %g\n', newInt);

fprintf('The new array is \n',array);

disp(array)

3 0
3 years ago
OO<br>(A) 3 and 5<br>(B) 4 and 8<br>(C) 2 and 0<br>(D) 6 and 9<br>2. There are twelve books on a shelf and four children in a ro
dlinn [17]

Explanation:

2.there will be 8 books left on the shelf if each child takes one

8 0
3 years ago
A _____ is a description that involves "telling" the database management system (DBMS) the logical and physical structure of the
alexandr402 [8]

Answer:

the right answer to the question is schema

Explanation:

The database schema of a database is its structure described in a formal language supported by the database management system (DBMS). The term "schema" refers to the organization of data as a blueprint of how the database is constructed

5 0
3 years ago
Other questions:
  • Which of the following describes a poor design consideration for a form?
    14·1 answer
  • friend wanted us to decode this message ----- .---- ----- ----- .---- ----- ----- .---- / ----- .---- .---- .---- ----- .---- .-
    11·1 answer
  • What’s of the following can be used to visually represent information similar to diagrams format painter Helens smart are a clip
    8·1 answer
  • On a chart created in excel, the horizontal axis is also called the ____.
    15·1 answer
  • What year did buck tooth bob become famous
    11·2 answers
  • What is an advantage and disadvantage to file compression
    8·1 answer
  • A tiny spot on an LCD monitor display screen that permanently remains black when it should be activated and displaying color is
    12·1 answer
  • The _____________ RTN describes the overall effectof instructions on the programmer visible registers
    9·1 answer
  • Suppose that​ 30% of the female students and​ 40% of the male students in a college history class are from a major city. If ther
    5·1 answer
  • onsider a file system on a disk that has both logical and physical block sizes of 512 bytes. assume that the information about e
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!