Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8933277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:30:02+00:00 2026-06-15T09:30:02+00:00

the program I’m doing requires me to use FileInputStream to calculate the grade point

  • 0

the program I’m doing requires me to use FileInputStream to calculate the grade point of a course.

The class I created, Course, has a method:

public double getGradePoint ()
{
    if (letterGrade == "A+" || letterGrade == "A")
        gradePoint = 4.0;
    if (letterGrade == "A-")
        gradePoint = 3.7;
    if (letterGrade == "B+")
        gradePoint = 3.3;
    if (letterGrade == "B")
        gradePoint = 3.0;
    if (letterGrade == "B-")
        gradePoint = 2.7;
    if (letterGrade == "C+")
        gradePoint = 2.3;
    if (letterGrade == "C")
        gradePoint = 2.0;
    if (letterGrade == "C-")
        gradePoint = 1.7;
    if (letterGrade == "D+")
        gradePoint = 1.5;
    if (letterGrade == "D")
        gradePoint = 1.0;
    if (letterGrade == "F")
        gradePoint = 0.0;

    return gradePoint;
}

And in the test client I have:

String subject;
String number;
String letGrade;

Course course1 = new Course ("ENGL", "1111", "D+");
FileInputStream file1 = new FileInputStream ("test transcript 1.txt");
Scanner readFile = new Scanner (file1);

while (readFile.hasNext ())
{
    course1.setSubject (readFile.next ());
    subject = course1.getSubject ();
    course1.setNumber (readFile.next ());
    number = course1.getNumber ();
    course1.setLetterGrade (readFile.next ());
    letGrade = course1.getLetterGrade ();
    course1.getGradePoint ();
    System.out.println (course1.toString ());
}

test transcript 1.txt contains:

COMP 1631   A-
ENGL 1101   B
MATH 1200   C+

But for some reason, when i use course1.getGradePoint (), it always returns as 0.0

After running the program:

COMP 1631   A-  (worth = 0.0)
ENGL 1101   B   (worth = 0.0)
MATH 1200   C+  (worth = 0.0)

I’ve tried using course1.getGradePoint () above the while command, like this:

String subject;
String number;
String letGrade;

Course course1 = new Course ("ENGL", "1111", "D+");
course1.getGradePoint ();

FileInputStream file1 = new FileInputStream ("test transcript 1.txt");
Scanner readFile = new Scanner (file1);

while (readFile.hasNext ())
{
    course1.setSubject (readFile.next ());
    subject = course1.getSubject ();
    course1.setNumber (readFile.next ());
    number = course1.getNumber ();
    course1.setLetterGrade (readFile.next ());
    letGrade = course1.getLetterGrade ();
    course1.getGradePoint ();
    System.out.println (course1.toString ());
}

Returns as:

COMP 1631   A-  (worth = 1.5)
ENGL 1101   B   (worth = 1.5)
MATH 1200   C+  (worth = 1.5)

It just won’t work with readFile.next () for some reason. If anyone could help me out, that would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:30:03+00:00Added an answer on June 15, 2026 at 9:30 am

    – Objects in Java are compared using equals(), and String is an Object in Java, so it follows the same rule.

    – == will be used to compare primitive or to check if two or more Object Reference Variables are pointing to the same Object on the heap or not.

    – So you should use equals() or equalsIgnoreCase() (if case doesn’t matters) to compare the String Objects.

    Eg:

    if (str1.equals(str2)){}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Program has more than one entry point defined: 'Class.Main()'. Compile with /main to specify
Program.cs class Program { public static void He(string v) { Console.WriteLine(v); Console.WriteLine(End?); } public
Program :main.cpp struct X { int x; }; export template <class T> T const&
This program so far has one purpose, take in two integers(the size of the
Program I'm making has a simple configuration file looking something like this. @overlays =
This program has the user input name / age pairs and then outputs them,
My program requires some configuration details to be kept in a .ini file. This
I am doing a simple coin flipping experiment for class that involves flipping a
/* Program to calculate trip and plan flights */ #define TRIP 6 #define NAMEMAX
{ class Program { static void Main(string[] args) { int id = 0, stock

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.