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

  • Home
  • SEARCH
  • 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 980771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:26:16+00:00 2026-05-16T04:26:16+00:00

Sorry for this guys, but I really am unlucky today. Please help, my problem

  • 0

Sorry for this guys, but I really am unlucky today.
Please help, my problem a while ago was that I’m having problems while looping, and now it cannot loop at all. It won’t let me enter the string to make it loop.
Name, and year and section also outputs as null. I also tried using try catch but it doesn’t seem to be picking up any errors.
Here’s the whole program. It just terminates, exactly on:

enter 1 to continue;

import java.util.*;

public class program
{
     public static Scanner rew= new Scanner(System.in);
    public static String name, yearandsec;
    public static char sex_code;

    public static int scode;
    public static double seq;
    public static int ccode;
    public static int units;
    public static double fee_per_unit;
    public static double misc;
    public static double gross;
  public static String dec;


    public static String decision;

    public static void main(String[] args) {
        String dec;
        do {
            System.out.println("Input info:");
            String name = stringGetter("Name: ");
            String yearandsec = stringGetter("Year and section: ");

 sex_code=charGetter("Sex code: " + "\n"  + "[M]" + "\n" + "[F]:");
        scode=intGetter("Scholarship code: ");
        ccode=intGetter("Course code: ");
        units=intGetter("Units: ");

        fee_per_unit=doubleGetter("Fee per unit: ");
        misc=doubleGetter("Miscellaneous: ");
        display();
         switches(scode, units, fee_per_unit, misc);

            dec = stringGetterz("Enter 1 to continue: ");
        } while(dec.equals("1"));
    }

    public static String stringGetterz(String ny){
        System.out.println(ny);
        return rew.nextLine();
    }


  public static char charGetter(String cg){
        String sc;
        char cc;
        System.out.print(cg);
        sc=rew.nextLine();
        cc=sc.charAt(0);
        return cc;

    }




   public static void switches(int scholar, int u, double fpu, double mi){
        double discnt=0;
        switch(scholar){
                case 1:
                    System.out.println("Scholarship: Full Scholar..");
                    discnt=1;
                    break;
                case 2:
                    System.out.println("Scholarship: Half Scholar..");
                   discnt=.50;
                    break;
                case 3:
                    System.out.println("Scholarship: Dean's Lister..");
                   discnt=.15;
                    break;
                case 4:
                    System.out.println("Scholarship: None..");
                   discnt=0;
                    break;
        }

        double gf;
        double disc;
        disc =(u * fpu) *discnt;
        gf=(u * fpu) + mi - disc;
       System.out.println(gf);


    }

    public static void switchcase(char gender, int corz){
        double discnt=0;
        switch(gender){
                case 'M':
                case 'm':
                    System.out.println("Sex: Male");
                    break;
                case 'F':
                case 'f':
                    System.out.println("Sex: Female");
                    break;
            }




            switch(corz){
                case 1:
                     System.out.println("Course: BSIT...");

                    break;
                case 2:
                     System.out.println("Course: BSCS..");
                     break;
                case 3:
                     System.out.println("Course: BSCOE..");
                     break;


            }




    }



    public static void display(){
        System.out.println("Name: " + name + "\n" + "Year and Section: " + yearandsec);
        System.out.println("Units enrolled: " + units + "\n" + "Fee per unit: " + fee_per_unit + "\n" + "Miscellaneous: " + misc);
        switchcase(sex_code, ccode);







    }

    public static double doubleGetter(String dg){
        double fm;
        System.out.println(dg);
        fm=rew.nextDouble();
        return fm;


    }
    public static int intGetter(String scu){
        int iget;
        System.out.println(scu);
        iget=rew.nextInt();
        return iget;

    }

    public static String stringGetter(String ny){
       String sget;
        System.out.println(ny);
       sget=rew.nextLine();
       return sget;

    }

}
  • 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-05-16T04:26:16+00:00Added an answer on May 16, 2026 at 4:26 am

    Static fields are initialized the first time you initialize an instance of the class, so until you make a new program(), those fields won’t exist. Also, those fields are not going to exist in the main function. rename your current main method to something like run and then use the following as a main method:

    public static void main(String args[]){
        program p = new program();
        p.run();
    }
    

    EDIT: Apparently I’m wrong, the code can run. Obviously, since you ran it…

    Your problem is fixed by changing rew.nextLine() to rew.next() in stringGetterz. Don’t know why.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for the wall of text guys but this one requires expliaining, way too
Sorry guys, I posted this earlier today where my add as linked images were
I'm sorry if this comes through as a noob question, but I'm really stuck
Sorry guys for the really simple question but I have tried to float one
Guys, I opened this question (I hope could help some others) but reading stackoverflow
Hey guys sorry this is a pretty long question but I cannot call printPASSInfo()
Sorry guys, didn't know how to word this one. Still learning jquery and have
Sorry this is a basic question, but all my research just barely missed answering
Sorry this is probably super basic. But in all my javabean examples, I've not
sorry this is such a simple question but I can't figure it out. How

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.