Thread Options Help Assistance needed in java for assignment

  • (2 Pages)
  • +
  • 1
  • 2

26 Replies - 588 Views - Last Post: 04 December 2017 - 04:55 PM Rate Topic: -----

#16 macosxnerd101  Icon User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12209
  • View blog
  • Posts: 45,287
  • Joined: 27-December 08

Re: Thread Options Help Assistance needed in java for assignment

Posted 04 December 2017 - 09:21 AM

View Postndc85430, on 04 December 2017 - 01:52 AM, said:

I already addressed two of the issues causing the error messages at the beginning of post 6. Have you tried addressing them in your code?

As for the third one, look at lines 100 and 101. An int doesn't have a length, does it?


Folks have already addressed these errors. Have you read their posts?
Was This Post Helpful? 0
  • +
  • -

#17 Dimlead  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 12
  • Joined: 03-December 17

Re: Thread Options Help Assistance needed in java for assignment

Posted 04 December 2017 - 11:24 AM

View Postmacosxnerd101, on 04 December 2017 - 09:21 AM, said:

View Postndc85430, on 04 December 2017 - 01:52 AM, said:

I already addressed two of the issues causing the error messages at the beginning of post 6. Have you tried addressing them in your code?

As for the third one, look at lines 100 and 101. An int doesn't have a length, does it?


Folks have already addressed these errors. Have you read their posts?


have an new problem:


Line: 101
method validateInput in class Assigment2 cannot be applied to given types;
required: java.lang.String
found: int
reason: actual argument int cannot be converted to java.lang.String by method invocation conversion

and the updated code:

/**
 * @(#)Assigment2.java
 *
 *
 * @author
 * @version 1.00 2017/12/1
 */

import java.util.Scanner;//java library class
public class Assigment2 {//start class

	//global variable
	static int creditsbalanceArray []={156,256,504};// user currency balance
    static String nameArray []={"Molly","Connor","Shane"};// user name
    static int passcodeArray []= {6543,7654,8765};// user passcode
    static int overdraftArray []={1,2,3};// user overdraft
    static int passcode;// user account passcode
    static int d;
    static int accountPasscode;
    static Scanner input = new Scanner(System.in);//static Scanner input
    static int index;// user index
	
	public static void main(String[] args) {//start main method

      	showAllUsers();//show All user variable
    	loginBankMachine();//login Bank Machine variable
    	showAlternativeOptions();//show Alternative Options variable
	
    }//end main method

    //METHODOLOGY||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    public static void showAllUsers(){//start showAllUsers method
		System.out.println("  All Users");// All Users
		System.out.println("INDEX\tNAME\t$ BAL\tPASSCODE");//user options
		for(int i=0;i<creditsbalanceArray.length;i++){//intializing credit balance Array
			System.out.println(i+"\t"+nameArray[i]+"\t"+creditsbalanceArray[i]+"\t"+passcodeArray[i]);//displaying arrays
		}// end for loop
    }//end showAllUsers method

    public static void loginBankMachine(){//start login method

        int found = 0;
        System.out.println("Welcome " + d+"\nPlease Enter Passcode : ");
        int passcode = input.nextInt();

    	//find the passcode in the array
    	for (int i = 0;i <accountPasscode.length;i++){
    		if (accountPasscode[i] == passcode ){
    			found = 1;
    			index = i;
    			break;
    		}//end if
    	}//end for

    	if (found == 0 ){
    		System.out.println("Not found Try again");
    		loginBankMachine();
    	}//end if
    }//end loginATM

    public static void showAlternativeOptions(){//start ShowAlternativeOption Method
    	System.out.println(" Please select one of the following options available");
		//give the user the menu
	   	System.out.print("\n1.View Bank Machine Produced Statment \n2.Deposit credits\n3.Withdraw credits\n4.Change Passcode\n5.Exit");//user options
	   	String option =input.next();//string option

	   	switch(option){//start switch method
	   		case "1":
	   			BankMachineProducedStatement();break;//BankMachineProducedStatment option
	   		case "2":
	   			System.out.println(" Deposit Credits");break;//Deposit Credits option
			case "3":
				System.out.println(" Withdraw Credits");break;//Withdraw Credits option
			case "4":
				System.out.println(" Change Passcode");break;//Change Passcode option
			case "5":
				System.out.println(" Thank you for using our bank machine");break;//Exit option
	   	}//end switch
    }// end ShowaAlternativeOption method

	public static void BankMachineProducedStatement(){//start BankMachineProducedStatement Method
		System.out.println(" Bank Machine Produced Statment");//Bank Machine Produced Statment Description
    	System.out.println(index+"\t"+nameArray[index]+"\t"+creditsbalanceArray[index]+"\t"+passcodeArray[index]);//initalizing arrays
	}//end BankMachineProducedStatement method

	public static void DepositCredits(){//start DepositCredits Method
		System.out.println(" Credits Total");//Credits Total Description
		System.out.println(" Credit ");
		System.out.println(index+"\t"+creditsbalanceArray[index]);//initalizing arrays
	}//end DepositCredits method

	public static void WithdrawCredits(){//start WithdrawCredits Method
		System.out.println("Credits Withdrawn");//Credit Withdrawm Description
		System.out.println(index+"\t"+creditsbalanceArray[index]);//index creditsbalanceArray
	}//end WithdrawCredits method

	public static void ChangePasscode(){

	System.out.println("\nEnter new passcode");
		String stringpasscode=input.next();
		int AccountPasscode=validateInput(passcode);
		for(int i=0;i<passcode.length;i++){
			if (AccountPasscode[i] == passcode){
				System.out.println("passcode taken");
				ChangePasscode();
			}//end if
		}//end for
	}//end changePasscode Method


	public static void Exit(){
		System.out.println("Thank you for using our bank machine");
		System.exit(0);
		}//end Exit method
		
			public static int validateInput(String stringInput){
	while(!stringInput.matches("\\d+")){
		System.out.println("Digits only Try again");
		stringInput=input.next();
		}
	return Integer.parseInt(stringInput);
	}	
}//end class


please help
Was This Post Helpful? 0
  • +
  • -

#18 ndc85430  Icon User is online

  • I think you'll find it's "Dr"
  • member icon

Reputation: 653
  • View blog
  • Posts: 2,708
  • Joined: 13-June 14

Re: Thread Options Help Assistance needed in java for assignment

Posted 04 December 2017 - 11:34 AM

What don't you understand? The variable passcode has type int and tAhe method validateInput takes a String. Check you're passing the right variable.

Also, you really need to sort out the indentation in this program.
Was This Post Helpful? 0
  • +
  • -

#19 macosxnerd101  Icon User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12209
  • View blog
  • Posts: 45,287
  • Joined: 27-December 08

Re: Thread Options Help Assistance needed in java for assignment

Posted 04 December 2017 - 11:39 AM

Do you mean to pass stringpasscode to the method?
Was This Post Helpful? 0
  • +
  • -

#20 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3485
  • View blog
  • Posts: 15,762
  • Joined: 20-September 08

Re: Thread Options Help Assistance needed in java for assignment

Posted 04 December 2017 - 11:56 AM

Mysterious. I suspect the person producing the code and the person asking the questions are different
Was This Post Helpful? 1
  • +
  • -

#21 macosxnerd101  Icon User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12209
  • View blog
  • Posts: 45,287
  • Joined: 27-December 08

Re: Thread Options Help Assistance needed in java for assignment

Posted 04 December 2017 - 12:03 PM

I would agree with that, but I can't find any evidence of this online.

Certainly this thread is begin cross-posted, with little evidence of effort elsewhere:
https://stackoverflo...ng-by-method-in
https://webcache.goo...=firefox-b-1-ab
Was This Post Helpful? 0
  • +
  • -

#22 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3485
  • View blog
  • Posts: 15,762
  • Joined: 20-September 08

Re: Thread Options Help Assistance needed in java for assignment

Posted 04 December 2017 - 12:07 PM

Well, it's funny how a missing method suddenly appeared after its absence mystified the OP ;) Someone being reluctantly nudged?
Was This Post Helpful? 0
  • +
  • -

#23 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13656
  • View blog
  • Posts: 54,499
  • Joined: 12-June 08

Re: Thread Options Help Assistance needed in java for assignment

Posted 04 December 2017 - 12:17 PM

.. or just got the answer from some other forum this has been seen on. You know.. because, you know, the OP "can learn later", and is chiefly concerned about "right now I need to get this assignment done".. even if they "don't learn anything from it and copy someone else's work". :rolleyes:
Was This Post Helpful? 0
  • +
  • -

#24 Dimlead  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 12
  • Joined: 03-December 17

Re: Thread Options Help Assistance needed in java for assignment

Posted 04 December 2017 - 12:41 PM

View Postmodi123_1, on 04 December 2017 - 12:17 PM, said:

.. or just got the answer from some other forum this has been seen on. You know.. because, you know, the OP "can learn later", and is chiefly concerned about "right now I need to get this assignment done".. even if they "don't learn anything from it and copy someone else's work". :rolleyes:/>



unfortunately I had to submit my assignment and I didn't get my problem solved, hopefully I at least pass the assignment, and no I would love to get the opportunity to learn about java, but this method that we're learning in college is just rushed and really frustrating and you don't learn shit this way. Btw any book you recommend that I can learn java from scratch, like I really don't know shit about java since my teacher is a dickhead who told me at the start of the year when I asked him a question about java that I should already know this from outside of college, complete utter dickhead, and it's very frustrating keeping up, especially when no one wants to help you and are secretive since they don't want to end up being accused of copying or cheating.
Was This Post Helpful? 0
  • +
  • -

#25 macosxnerd101  Icon User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12209
  • View blog
  • Posts: 45,287
  • Joined: 27-December 08

Re: Thread Options Help Assistance needed in java for assignment

Posted 04 December 2017 - 12:43 PM

Academic integrity is a legitimate concern, especially since you have stated you copy solutions from the internet. I canít speak to the quality of the instructor nor will I attempt to do so.

If you are looking for book recommendations, we have a pinned thread: http://www.dreaminco...beginners-book/
Was This Post Helpful? 0
  • +
  • -

#26 Dimlead  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 12
  • Joined: 03-December 17

Re: Thread Options Help Assistance needed in java for assignment

Posted 04 December 2017 - 04:53 PM

View Postmacosxnerd101, on 04 December 2017 - 12:43 PM, said:

Academic integrity is a legitimate concern, especially since you have stated you copy solutions from the internet. I canít speak to the quality of the instructor nor will I attempt to do so.

If you are looking for book recommendations, we have a pinned thread: http://www.dreaminco...beginners-book/



Do you also know any websites by the way, since I don't know if I can find those books in my local book store, it might take some time, so any websites for java learning that are very easy to understand for beginners, and maybe with a more advanced category once I understand the basics, that would help a lot thanks.
Was This Post Helpful? 0
  • +
  • -

#27 macosxnerd101  Icon User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12209
  • View blog
  • Posts: 45,287
  • Joined: 27-December 08

Re: Thread Options Help Assistance needed in java for assignment

Posted 04 December 2017 - 04:55 PM

Start here!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2