write a program which asks the user how many days they will be working. then using your program calculate and print the amount of money they will earn if paid £1 for day 1, £3 for day 2, £9 for day 3 etc.....i have coded the inputing of name and work days i know there are if statements but how do i use them? thanks for your help. appreciated :)

......................................…
import java.util.*;
class Assignment3
public static void main(String[] args) {
String name;
String days;
Scanner scanner = new Scanner(System.in);

System.out.println("Please Enter Your Name");
name= scanner.nextInt();
System.out.println("How many days will you be working?");
days= scanner.nextInt();

You need a for loop, not an if statement. http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html
You need to declare two integer variables outside of your for loop. One to keep track of the total amount of money earned, and one to keep track of the amount you need to add next time. For example, the first time around, the "amount to add" will be 1, then 3, then 9, then 27.

Inside your for loop, you need to add the current "amount to add" to your total, then update the "amount to add" variable by multiplying it by three. Good luck.

You need a for loop, not an if statement. http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html
You need to declare two integer variables outside of your for loop. One to keep track of the total amount of money earned, and one to keep track of the amount you need to add next time. For example, the first time around, the "amount to add" will be 1, then 3, then 9, then 27.

Inside your for loop, you need to add the current "amount to add" to your total, then update the "amount to add" variable by multiplying it by three. Good luck.

thanks a lot for the advice...would you be as kind to upload the code needed? i'd be really thankful as the program has to be submitted tomorrow and my tutor in college is no help! thank you :)

commented: You posted 4 lines of code to fool us that you showed some effort -1

thanks a lot for the advice...would you be as kind to upload the code needed? i'd be really thankful as the program has to be submitted tomorrow and my tutor in college is no help! thank you :)

Waste of time. Someone ban this kid.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.