r/learnjava • • Oct 25 '26

Need help

This is for an APCSA assignment on Idecl.

My code technically works but when I run tests the "readSwitchesFromUser" method keeps creating this specific error:

/app/TestMinivan.java:97: error: method readSwitchesFromUser in class Minivan cannot be applied to given types;
        van.readSwitchesFromUser();
           ^
  required: int,int,int,int,int,int,int,int,String
  found:    no arguments
  reason: actual and formal argument lists differ in length

I know I have to turn the readSwitchedFromUser method into a scanner but I have no clue how to go about it.

Below is the program I wrote:

import java.util.Scanner;

public class Minivan{

  private int dashLeft;       // 0 = switch disengaged; 1 = switch engaged
  private int dashRight;      // 0 = switch disengaged; 1 = switch engaged
  
  private int childLock;      // 0 = off; 1 = activated
  private int masterUnlock;   // 0 = off; 1 = activated
  
  private int insideLeft;     // 0 = switch disengaged; 1 = switch engaged
  private int outsideLeft;    // 0 = switch disengaged; 1 = switch engaged
  
  private int insideRight;    // 0 = switch disengaged; 1 = switch engaged
  private int outsideRight;   // 0 = switch disengaged; 1 = switch engaged

  private String gearSetting;  
         /* Options include: P(ark) N(eutral) D(rive) 1(st gear)
                             2(nd gear) 3(rd gear) R(everse) */

  public static void main(String[] args){

        Minivan mv = new Minivan();  
              // This creates a new minivan with the name mv.  
              // If you don't like that name, feel free to change it.
        // Complete the main method here.  
        // Be sure to create a series of your own tests to 
        // ensure the program runs as expected.
        setSwitches();
  }

public static void setSwitches(int s1, int s2, int s3, int s4, int s5, int s6, int s7, int s8, String gearShift){
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter accetable value (eight strings, each followed by a comma, and a gear in quotes): ");
        // getting each individual input from the user
        String S1 = sc.nextLine();
        String S2 = sc.nextLine();
        String S3 = sc.nextLine();
        String S4 = sc.nextLine();
        String S5 = sc.nextLine();
        String S6 = sc.nextLine();
        String S7 = sc.nextLine();
        String S8 = sc.nextLine();
        String gear = sc.nextLine();
        
        S1 = S1.substring(0, 1);
        S2 = S2.substring(0, 1);
        S3 = S3.substring(0, 1);
        S4 = S4.substring(0, 1);
        S5 = S5.substring(0, 1);
        S6 = S6.substring(0, 1);
        S7 = S7.substring(0, 1);
        S8 = S8.substring(0, 1);
        
        int s1 = Integer.parseInt(S1);
        int s2 = Integer.parseInt(S2);
        int s3 = Integer.parseInt(S3);
        int s4 = Integer.parseInt(S4);
        int s5 = Integer.parseInt(S5);
        int s6 = Integer.parseInt(S6);
        int s7 = Integer.parseInt(S7);
        int s8 = Integer.parseInt(S8);
        
        // s1 = dashLeft
        // s2 = dashRight
        // s3 = childLock
        // s4 = masterUnlock
        // s5 = insideLeft
        // s6 = outsideLeft
        // s7 = insideRight
        // s8 = outsideRight
        // I dont know why I named it like that, I dont really know what the s stands for.
        
        //making sure the conversion is working 
        System.out.println(s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8);
        readSwitchesFromUser(s1, s2, s3, s4, s5, s6, s7, s8, gear);
    }
  

    public static void checkDoors(int s1, int s2, int s3, int s4, int s5, int s6, int s7, int s8, String gearShift){
  // Write the method checkDoors here.
        if ((!gearShift.equals("P")) || s4 != 0){
            System.out.println("both doors closed");
        }
        
        boolean leftDoorOpen = false;
        boolean rightDoorOpen = false; 
        
        if ((s1 == 1 || s5 == 1 || s6 == 1) && s3 == 0){
            leftDoorOpen = true;
        }
        if ((s2 == 1 || s7 == 1 || s8 == 1) && s3 == 0){
            rightDoorOpen = true;
        }
        
        if (rightDoorOpen && leftDoorOpen){
            System.out.println("both doors open");
        }
        else if (rightDoorOpen && !leftDoorOpen){
            System.out.println("right door open");
        }
        else if (!rightDoorOpen && leftDoorOpen){
            System.out.println("left door open");
        }

        
        
  

    }
}
0 Upvotes

3 comments sorted by

View all comments

1

u/EntrepreneurHuge5008 Oct 25 '26

My code technically works but when I run tests the "readSwitchesFromUser" method keeps creating this specific error:

The error is telling that that specific method is expecting you to give it some values:

required: int,int,int,int,int,int,int,int,String

If you didn't write this method, find where it is in the code, and I bet you there's a comment telling you what it is for and what it expects.