mardi 22 mars 2016

A java program for Tuition

We need use Parameters, return values, if-statements, user input validation, interactive input, formatted output. The requirements are:enter image description here

I did this program by myself, but there are a lot of bugs. I don't know why and so I did not finish it, I need the last step, and I have some problem to calculate the final tuition.

Here is my coding:

import java.util.*;
public class Tuition {

   public static void main (String[] args) {

      Scanner kb = new Scanner(System.in);

      int hour = getHours(kb);

      char major = getMajor(kb);

      char status =  getStatus(kb);

      double tuition = calculateTuition(hour,major,status);

      displayTuition(hour,major,status,tuition);
   }

  public static void displayTuition() {
     System.out.println("Credit Hours:"+hour);
     System.out.println("Major:"+major);
     System.out.println("Residencey"+status);
     System.out.println("Tuition = "+tuition);
   } 

  public static void getHours() {
     Scanner consloe = new Sacnner(System.in);
     System.out.print("How many credit hours did you take:");
     int hour = console.nextInt();
  }

  public static void getMajor() {
     Scanner kb = new Scanner(System.in);
     System.out.print("What's your major?");
     char major = kb.next();
     if (major == C||major == c) {
        getmajor = "Computer Since";
     } else if (major == O||major == o) {
      getmajor = "other science";
     } else if (major == X||major == x) {
        getmajor = "Non-Science";
     }
  }
  public static void getStatus() {
     Scanner kb = new Scanner(System.in);
     System.out.print("You are in state student or not(yes for Y/y,no for N/n)");
     char state = kb.next();
     if (state == Y||state == y) {
        getmajor = "In-State";
     } else if (major == N||major == n) {
        getmajor = "Out-of-State";
     } else {
        return getStatus;
     }
 }
}

Thanks for helping guys!

Aucun commentaire:

Enregistrer un commentaire