I have Pasted 2 java Files below
1 is Student.java
2nd is Lab7.java
Student.java
package com.program.abc;
/*---------------------------------------------------------
// AUTHOR: your name
// ASU ID: your 10 digits ASU ID
// FILENAME: title of the source file
// SPECIFICATION: description of the program
// TIME SPENT: how long it took you to complete the lab
//-------------------------------------------------------*/
public class Student {
private int studentID;
private String firstName;
private String lastName;
private String major;
private int gradePoints;
private int totalCredits;
public Student(int studentID, String
firstName, String lastName, String major, int gradePoints, int
totalCredits) {
this.studentID =
studentID;
this.firstName =
firstName;
this.lastName =
lastName;
this.major =
major;
this.gradePoints =
gradePoints;
this.totalCredits =
totalCredits;
}
public int getID() {
return studentID;
}
public String getFullName() {
return firstName + " " +
lastName;
}
public String getMajor() {
return major;
}
public int getGradepoints() {
return
gradePoints;
}
public int getCredits() {
return
totalCredits;
}
public void changeMajor(String major) {
this.major =
major;
}
public void changemajor(String newMajor, int newPoints, int newCredits) {
if ((newPoints <=
this.gradePoints) && (newCredits <= this.totalCredits))
{
this.major = newMajor;
} else {
System.out.println("Invalid attempt");
}
}
@Override
public String toString() {
System.out.println("================================================");
return
String.format("%s\n%s\n%s\n%s\n%s\n", "Student ID : " +
String.valueOf(getID()), "Student Name: " + getFullName(), "Major :
" + getMajor(), "Num of Points: " +
String.valueOf(getGradepoints()), "Total Credits: " +
String.valueOf(getCredits()));
}
}
Lab7.java
package com.program.abc;
import java.util.Scanner;
/*---------------------------------------------------------
// AUTHOR: your name
// ASU ID: your 10 digits ASU ID
// FILENAME: title of the source file
// SPECIFICATION: description of the program
// TIME SPENT: how long it took you to complete the lab
//-------------------------------------------------------*/
public class Lab7 {
public static void main(String[] args) {
String
firstName;
String lastName;
String fullName;
String major;
String oldMajor;
int studentId;
int points;
final int totalCredits =
100;
Scanner scan = new Scanner(System.in);
System.out.println("Enter first Name: ");
firstName =
scan.next();
System.out.println("Enter last Name: ");
lastName =
scan.next();
System.out.println("Enter student major: ");
major =
scan.next();
System.out.println("Enter student ID: ");
studentId =
scan.nextInt();
System.out.println("Enter # of points: ");
points =
scan.nextInt();
Student student1 = new Student(studentId, firstName, lastName, major, points, totalCredits);
fullName =
student1.getFullName();
System.out.println("Student Name: " + fullName);
System.out.println("Student ID: " + student1.getID());
System.out.println();
System.out.println(student1.toString());
oldMajor = student1.getMajor();
System.out.println("Do you want to Change the major - Yes/No");
String yes_no = scan.next();
if
(!oldMajor.equals(major) || yes_no.equals("yes".toLowerCase()))
{
student1.changemajor(major, points, totalCredits);
student1.changeMajor(major);
System.out.println("Student has changed major from " + oldMajor + "
to " + major);
student1.toString();
}
}
}
This code is tested and Change the author name and other names accordingly.
What this Lab Is About: Given a UML diagram, learn to design a class Learn how...
Here is the code from the previous three steps: #include <iostream> using namespace std; class Student { private: //class variables int ID; string firstName,lastName; public: Student(int ID,string firstName,string lastName) //constructor { this->ID=ID; this->firstName=firstName; this->lastName=lastName; } int getID() //getter method { return ID; } virtual string getType() = 0; //pure virtual function virtual void printInfo() //virtual function to print basic details of a student { cout << "Student type: " << getType() << endl; cout << "Student ID: " << ID...
1) This exercise is about Inheritance (IS-A) Relationship. A) First, draw the UML diagram for class Student and class ComputerSystemsStudent which are described below. Make sure to show all the members (member variables and member functions) of the classes on your UML diagram. Save your UML diagram and also export it as a PNG. B) Second, write a program that contains the following parts. Write each class interface and implementation, in a different .h and .cpp file, respectively. a) Create...
Create a UML diagram to help design the class described in exercise 3 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Baby class object; should they be private or public? Determine what class methods are required; should they be private or public? Write Java code for a Baby class. A Baby has a name of type String and an age of type integer. Supply two constructors:...
Writing 3 Java Classes for Student registration /** * A class which maintains basic information about an academic course. */ public class Course { /** * Attributes. */ private String code; private String title; private String dept; // name of department offering the course private int credits; /** * Constructor. */ public Course(String code, String title, int credits) { // TODO : initialize instance variables, use the static method defined in // Registrar to initialize the dept name variable...
Question 1 (4 mark): Implement a program with two classes according to the following UML diagram: College -firstLab Student: StudentAccount - secondLab Student: StudentAccount +main (String (1) : void +College (String, String, int, int) : +printStudents(): void contains StudentAccount -name: String -studentNumber: int StudentAccount (String, int): +getName(): String +getStudentNumber(): int 2 REQUIREMENTS • The constructor College (String, String, int, int) shall create two component objects of type StudentAccount, i.e., the first lab student and the second lab student, and initialize...
Write a Java class named Employee to meet the requirements described in the UML Class Diagram below: Note: Code added in the toString cell are not usually included in a regular UML class diagram. This was added so you can understand what I expect from you. If your code compiles cleanly, is defined correctly and functions exactly as required, the expected output of your program will solve the following problem: “An IT company with four departments and a staff strength...
Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc).Keep identifiers to a reasonably short length.Use upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables, methods, objects).Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes, methods, and code associated with ifs, switches and loops. Be consistent with the number of spaces or...
Introduction In this lab, you will be working with three classes: Person, Student, and Roster. Person and Student represent individuals with a first and last name as String class variables, and Student has an additional int class variable that represents a ID number. The Roster class represents a group of people that are objects of either the Person or Student class. It contains an ArrayList. The Person class has been completed for you with class variables, a constructor, and a...
I wrote some code and it builds but everytime I run it, It shows the error message in the else statement ASU CSE 100 Lab #7 Due date/Time: Friday, Oct. 13th, 2017 at 5:30pm What this Lab Is A Learn to create and use istream object to read data from a text file Learn to create and use ofstream object to write program output into a text file Learn to use a while loop to read a text file line...
To conclude the project, use the UML diagram you created last week and create an application in Visual Studio named School. Once you have written the code, be sure and test it to ensure it works before submitting it. Below is the UML diagram for the basic class we created last week for your reference, but for this project be sure you use the one that you created last week. Good luck and be sure to get started early in...