Getting started

Hi guys! My name is Josh and I’m relatively new to programming. I am a student at Kennesaw State University and am finishing up my second semester of Java programming. Currently, I wish to hone my skills, as I know they’re lacking, to say the least. I have the basic concepts and syntax down, but freeze when it comes to working problems. My brain isn’t wired to do logical operations. I’m looking for help with the ATM problem. For some reason, when I call my double variable, withdraw, and tell it to withdraw = in.nextDouble, the compiler complains about the dot notation. Can someone please provide guidance? Below is a copy of what I have, along with the error message I receive.
/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner in = new Scanner(System.in);
double balance = 120.00;
double withdraw = 0;

	System.out.println("Your current balance is: " + balance + "\n");
	System.out.println("Enter the ammount you wish to withdraw: ");
	withdraw = in.nextDouble;
}

}

Main.java:18: error: cannot find symbol
withdraw = in.nextDouble;
^
symbol: variable nextDouble
location: variable in of type Scanner
1 error

Firstly, Format your code., otherwise we can’t figure out what’s wrong.

withdraw = in.nextDouble();

seems to solve the error.

1 Like

Thank you, that was a misfortunate oversight on my part.

I’m testing to see if this does what the tutorial says:

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner in = new Scanner(System.in);
double balance = 120.00;
double withdraw = 0;

	System.out.println("Your current balance is: " + balance + "\n");
	System.out.println("Enter the ammount you wish to withdraw: ");
	withdraw = in.nextDouble;
}


}

Main.j

When you create a comment, it gives you a preview of what your comment will look like, to the right. You don’t have to actually post to see it.

I’ve figured that out. This was my first post; sorry for not knowing the SOP