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

HW3_P1 - Student list using array

Computers and Technology
1 answer:
Greeley [361]3 years ago
3 0

Answer:

#include<iostream>

#include<cstring>

#include <algorithm>

using namespace std;

class Student{

public:

string name;

int rollNo;

Student(){

}

Student(string n, int r){

name = n;

rollNo = r;

}

};

class ClassRoom{

public:

Student stud[10];

int count;

ClassRoom(){

count = 0;

}

void addStudent(string str,int roll){

Student s(str,roll);

stud[count++] = s;

}

Student * getAllStudents(){

return stud;

}

};

int main()

{

string name;

char temp[20];

int rollNo, N, i;

Student * students;

ClassRoom classRoom;

i=0;

while(getline(cin, name) && cin.getline(temp,20)&&i<10){

rollNo = atoi(temp);

classRoom.addStudent(name, rollNo);

i++;

}

N = i;

students = classRoom.getAllStudents();

for(int i=0 ; i < N; i++){

cout << (students+i)->rollNo << " - " << (students+i)->name;

if(i<N-1)

cout<<endl;

}

return 0;

}

Explanation:

  • In the addStudent method, increment the counter and as the value of variable s to the the stud array.
  • In the getAllStudents method, return all the students.
  • Finally in the main method, display the name and roll no. of students.
You might be interested in
Define get_date() function.
lyudmila [28]

Answer:

I believe it returns the current database system date and time, in a 'YYYY-MM-DD hh:mm:ss.mmm' format.

8 0
4 years ago
Which of the following is NOT one of the most important elements when designing a website?
Dmitriy789 [7]
Screen resulution Hope this helps
7 0
3 years ago
Read 2 more answers
List out any four hardware and software components required for multimedia​
natta225 [31]

Answer:

The list of hardware components required in multimedia are as follows:

  • Microprocessor.
  • High storage hard disk.
  • RAM.
  • High resolution graphics cards.

The list of software components required in multimedia are as follows:

  • Text
  • Audio
  • Graphics
  • Video
3 0
2 years ago
Write a method maxMagnitude() with two integer input parameters that returns the largest magnitude value. Use the method in a pr
yawa3891 [41]

Answer:

The program in Java is as follows:

import java.util.*;

import java.lang.Math;

public class Main{

public static int maxMagnitude(int num1, int num2){

    int mag = num2;

    if(Math.abs(num1) > Math.abs(num2)){

        mag = num1;

    }

    return mag;

}

public static void main(String[] args) {

 int num1, num2;

 Scanner input = new Scanner(System.in);

 System.out.print("Enter two integers: ");

 num1 = input.nextInt();

 num2 = input.nextInt();

 System.out.println(maxMagnitude(num1,num2));

}

}

Explanation:

The method begins here

public static int maxMagnitude(int num1, int num2){

This initializes the highest magnitude to num2

    int mag = num2;

If the magnitude of num1 is greater than that of num2

    if(Math.abs(num1) > Math.abs(num2)){

mag is set to num1

        mag = num1;

    }

This returns mag

    return mag;

}

The main  method begins here

public static void main(String[] args) {

This declares num1 and num2 as integer

 int num1, num2;

 Scanner input = new Scanner(System.in);

This prompts the user for two integers

 System.out.print("Enter two integers: ");

This gets input for the first integer

 num1 = input.nextInt();

This gets input for the second integer

 num2 = input.nextInt();

This calls the maxMagnitude method and prints the number with the highest magnitude

 System.out.println(maxMagnitude(num1,num2));

}

3 0
3 years ago
Es el conjunto de manifestaciones materiales, intelectuales y espirituales que distinguen a un pueblo a)Civilización b)Cultura c
GREYUIT [131]

Answer:

a)Civilización

Explanation:

3 0
3 years ago
Other questions:
  • Marie uses a browser to visit a blog. What is the unique identifier of the blog? A. web page B. website C. web address D. email
    7·2 answers
  • Select the correct answer.
    9·1 answer
  • A network administrator notices that some newly installed Ethernet cabling is carrying corrupt and distorted data signals. The n
    8·1 answer
  • After which stage in the information processing cycle can data be referred for future use?
    7·1 answer
  • What is the full form of icimod?
    6·1 answer
  • Select the correct answer.
    15·1 answer
  • Help with this please anyone
    15·2 answers
  • Well the last week has been kind of terrible...
    9·2 answers
  • Hello guys please help me <br>list and identify the components of computer ​
    15·1 answer
  • The rectangular symbol in flowchart<br> is used to denote dash
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!