Question

Rewrite the following C++ class into Java, don't forget to put main into the Student class....

Rewrite the following C++ class into Java, don't forget to put main into the Student class.
 
class Student { 
    std::string lname;
 
    std::string fname;
 
    int age;
 
    double gpa;
 
    Student(const std::string& lname, const std::string& fname, int age, double gpa);
 
    std::string lname() const;
 
    std::string fname() const;
 
    int age() const;
 
    double gpa() const;
 
    friend std::ostream& operator<<(std::ostream& os, const Student& st);
};
 
int main(int argc, const char* argv[]);

Homework Answers

Answer #1

public class Student

{

private String lName;

private String fName;

private int age;

private double gpa;

  public Student(String lname, String fname, int age, double gpa);
 
   public String lname();
 
   public String fname();
 
   public int age();
 
public double gpa();

public String toString()

    {

        return lName+ " " + fName+ " " + toString(age) + " " + toString(gpa);

    }

public static void main(String[] args)

    {

        

    }

{

Know the answer?
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
Similar Questions
How do I fix my error of binding on line 74? #include <iostream> #include <fstream> #include...
How do I fix my error of binding on line 74? #include <iostream> #include <fstream> #include <cctype> #include <cstring> #include <iomanip> using namespace std; #include "AvlTree.h" class WordCount { public:     char *word;     int *lines;     int count;     int size;     bool operator<(const WordCount &rhs) const {return strcmp(word, rhs.word) < 0;}     bool operator!= (const WordCount &rhs) const {return strcmp(word, rhs.word) != 0;}     WordCount():lines(NULL), count(0), size(0) {word = new char[1]; word[0] = '\0';}     friend ostream& operator<<...
IN C++ format, Fill in the missing functions, using the concept of operator overloading. code: #include...
IN C++ format, Fill in the missing functions, using the concept of operator overloading. code: #include <string> #include <ostream> using namespace std; class Book { private:     string title;     string author;     unsigned isbn;     double price; public: /**Constructors*/    Book();    Book(string t, string a, unsigned i, double p);     /**Access Functions*/     string get_title();     string get_author();     unsigned get_isbn();     double get_price();     /**Manipulation Procedures*/    void set_title(string t);     void set_author(string a);     void set_isbn(unsigned...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input operator>> a bigint in the following manner: Read in any number of digits [0-9] until a semi colon ";" is encountered. The number may span over multiple lines. You can assume the input is valid. Overload the operator+ so that it adds two bigint together. Overload the subscript operator[]. It should return the i-th digit, where i is the 10^i position. So the first...
Convert this C++ to JavaScript and run in browser. #include <cstdlib> #include <ctime> #include <sstream> #include...
Convert this C++ to JavaScript and run in browser. #include <cstdlib> #include <ctime> #include <sstream> #include <iostream> using namespace std; /* * */ class Dice{ private: static const int MAXDICE=6; static const int MINDICE=1; int faceVal; public: Dice(int); void setFace(int); int getFace(); string toString(); }; Dice::Dice(int faceVal) { if(faceVal<MINDICE&&faceVal>MAXDICE) { setFace(1); } else { this->faceVal=faceVal; } } void Dice::setFace(int faceVal) { this->faceVal=faceVal; } int Dice::getFace() { return faceVal; } string Dice::toString() { stringstream ss; ss<<faceVal; string str="face value is ";...
"C language" Take this code and make the minor modification necessary to create a circular linked...
"C language" Take this code and make the minor modification necessary to create a circular linked list (Hint: Store a pointer to the first node in the next pointer of the last node.) Demonstrate that this is working by traversing the list until the first pointer is encountered 3 times. Next redefine the node structure to include a back pointer. This will enable your program to move from front to back and then from back to front. It is not...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 565 Error 2 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 761 I need this code to COMPILE and RUN, but I cannot get rid of this error. Please Help!! #include #include #include #include using namespace std; enum contactGroupType {// used in extPersonType FAMILY, FRIEND, BUSINESS, UNFILLED }; class addressType { private:...
Something is either messed up in my operator overload <<, covertopostfix function, or my main output....
Something is either messed up in my operator overload <<, covertopostfix function, or my main output. Cannot figure it out. please help. Please comment your changes too. Program below is supposed to be outputting like this: InFix is:   A+B-C Post fix is:   A B + C - InFix is:   A+C Post fix is:   A C + InFix is:   x*(y+z)-(w+t) Post fix is:   x y z + * w t + - InFix is:   A+B*(C+D)-E/F+G+H Post fix is:   A B C...
Using the C programming language implement Heapsort in the manner described in class. Here is some...
Using the C programming language implement Heapsort in the manner described in class. Here is some example code to use as a guideline. Remember, you need only implement the sort algorithm, both the comparison and main functions have been provided. /* * * after splitting this file into the five source files: * * srt.h, main.c, srtbubb.c, srtinsr.c, srtmerg.c * * compile using the command: * * gcc -std=c99 -DRAND -DPRNT -DTYPE=(float | double) -D(BUBB | HEAP | INSR |...
IN JAVA Complete the following program. Add codes in the main method to:1) call method average(double[]...
IN JAVA Complete the following program. Add codes in the main method to:1) call method average(double[] gpaarr ) to calculate the average of gpaArray; 2) add codes in the for loop to calculate sum 3) print the average . public class Test { public static void main (String args[]) { double[ ] gpaArray = { 2.5, 4.0, 3.8, 3.2, 2.9, 4.0 } ;   //add your codes here (you can put your codes in the Answer area with/without copying the original...
1.Select all C++ functions that must be defined for implementing deep copies in your class which...
1.Select all C++ functions that must be defined for implementing deep copies in your class which has instance variables pointing to dynamic memories. Group of answer choices a.Default Constructor b.Copy Constructor c.Overloading assignment operator d.Writing own friend functions to directly access dynamically allocated memories e.Writing own destructor to free the allocated memory f.Overloading new operator 2. Match the memory source (right side) of the variables (left side) of the following code snippet which is a part of 'myProg' program. Note...