Question

Hey, I have an assignment from my Data Structures class. I need the output to be:...

Hey, I have an assignment from my Data Structures class. I need the output to be:

[1] to set the student name
[2] to set the student address
[3] to set the student GPA
[4] to set the student student ID
[5] to set the student major
[6] to print student info
[7] to exit

Then I need this output to repeat another 2 times. How can I code that? Its java

Also, to code the output above, I used

int a = 1;
System.out.println("[" + a + "] to set the student name");

I repeated this code until

int g = 7

Please help. Thanks in advance

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;

class Sol{

public static void main(String[] args)  
{
int a=1;
for(int i=0;i<3;i++)
{
System.out.println("[" + a + "] to set the student name");
System.out.println("[" + (a+1) + "] to set the student address");
System.out.println("[" + (a+2) + "] to set the student GPA");
System.out.println("[" + (a+3) + "] to set the student student ID");
System.out.println("[" + (a+4) + "] to set the student major");
System.out.println("[" + (a+5) + "] to print student info");
System.out.println("[" + (a+6) + "] to exit");
  
System.out.println();
  
}
  

}
  
}

Add a comment
Know the answer?
Add Answer to:
Hey, I have an assignment from my Data Structures class. I need the output to be:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • java This lab is intended to give you practice creating a class with a constructor method,...

    java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...

  • Hey, I have this homework from my data structures class using java that I am having...

    Hey, I have this homework from my data structures class using java that I am having difficulties coding. I had to create an abstract class Shape, which contains two protected instance variables color(String) and filled(boolean). Getter and setter for all the instance variables, and toString(). Two abstract methods getArea() and getPerimeter(). The part that I am not sure how to code is: for the subclasses of Shape which are Circle and Rectangle I have to override the abstract methods getArea()...

  • Hey, I have this Data Structures homework Im struggling to finish. I need to Define a...

    Hey, I have this Data Structures homework Im struggling to finish. I need to Define a class Worker derived from Human with fields WeekSalary and WorkHoursPerDay and method MoneyPerHour() that returns the payment earned by hour by the worker. And I have to initialize a list of 10 workers and sort them by payment per hour in descending order. I have already created the super class Human holding a first name and a last name. As Worker extends human. Please...

  • Hey, need some help in Java. I'm stuck on one step that prevents me from doing...

    Hey, need some help in Java. I'm stuck on one step that prevents me from doing the rest of the steps and need help on it. I also have a problem when I print databaseCourse and programmingCourse. instead of saying 5 and 7 respectively is shows 51 and 71. Step 8: in CourseGrades, create a method, add, that takes two parameters, studentNum and grade, and changes the grade of student studetNum to the given grade, grade. studentNum represents the student...

  • Hello, we are currently learning the compareTo() method in my Java Data Structures class. I am...

    Hello, we are currently learning the compareTo() method in my Java Data Structures class. I am having trouble understanding what the output here will be: a = "ballD"; b= "ballDs"; System.out.println(a.compareTo(b)); I don't know how to interpret the small "s". I know that if it was a = "ballD"; b = "ballD"; the output would be 0. Please help, thanks in advance

  • I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student...

    I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student {    private String name;    private double gpa;    private int idNumber;    public Student() {        this.name = "";        this.gpa = 0;        this.idNumber = 0;    }    public Student(String name, double gpa, int idNumber) {        this.name = name;        this.gpa = gpa;        this.idNumber = idNumber;    }    public Student(Student s)...

  • How would this switch statement be modified to not use "continue"? This piece of code is...

    How would this switch statement be modified to not use "continue"? This piece of code is part of a larger assignment and that assignment prohibits the use of "continue" for switch statements. How do I modify this code so that it still does what I want it to do, without using "continue"? while (true) { choice = displayMenu(keyboard); switch (choice) { case 'D': case 'd': { courseStudents.displayStudentList();    continue; } case 'A': case 'a': { int id; double stGpa; System.out.println("Enter...

  • Hey I really need some help asap!!!! I have to take the node class that is...

    Hey I really need some help asap!!!! I have to take the node class that is in my ziplist file class and give it it's own file. My project has to have 4 file classes but have 3. The Node class is currently in the ziplist file. I need it to be in it's own file, but I am stuck on how to do this. I also need a uml diagram lab report explaining how I tested my code input...

  • Hi everyone! I need help on my Java assignment. I need to create a method that...

    Hi everyone! I need help on my Java assignment. I need to create a method that is called sumIt that will sum two values and will return the value.It should also invoke cubeIt from the sum of the two values. I need to change the currecnt program that I have to make it input two values from the console. The method has to be called sumIt and will return to the sum that will produce the cube of the sum...

  • Create a java project and create Student class. This class should have the following attributes, name...

    Create a java project and create Student class. This class should have the following attributes, name : String age : int id : String gender : String gpa : double and toString() method that returns the Student's detail. Your project should contain a TestStudent class where you get the student's info from user , create student's objects and save them in an arralist. You should save at least 10 student objects in this arraylist using loop statement. Then iterate through...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT