#Can anyone help me with my Assignment? It's due in 1 hour
96 messages · Page 1 of 1 (latest)
Furthermore, your int payday needs to be Monday + Tuesday + Wednesday + Thursday + Friday;
Not commas
ints aren't a list
Also what are you doing with all of those doubles
Sorry I pasted some wrong lines,
Finally, to make the program less confusing, I would do System.out.println("Please enter the amount of hours you worked on Monday: ");
All good
I'm trying to solve the exercise
Right
i tried it this way but it's wrong
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
int monday_pay = 0;
double tuesday_pay = 0;
double wednesday_pay = 0;
int thursday_pay = 0;
int friday_pay= 0;
System.out.println("Please enter the time you left on Monday: ");
int Monday = input.nextInt();
System.out.println("Please enter the time you left on Tuesday: ");
int Tuesday = input.nextInt();
System.out.println("Please enter the time you left on Wednesday: ");
int Wednesday = input.nextInt();
System.out.println("Please enter the time you left on Thursday: ");
int Thursday = input.nextInt();
System.out.println("Please enter the time you left on Friday: ");
int Friday = input.nextInt();
if ( Monday == 4 ) {
monday_pay = 49;
}
if ( Tuesday == 5 ) {
tuesday_pay = 49 + 10.5;
}
if ( Wednesday == 6 ) {
wednesday_pay = 49 + 10.5 + 10.5;
}
if ( Thursday == 4 ) {
thursday_pay = 49;
}
if ( Friday == 4 ) {
friday_pay = 49;
}
double weekly_payment = monday_pay + tuesday_pay + wednesday_pay + thursday_pay + friday_pay;
double tax = weekly_payment*0.03;
double net_salary = weekly_payment-tax;
System.out.println("Your total weekly salary is " + weekly_payment);
System.out.println("The tax in your salary is " + tax);
System.out.println("Your net salary is " + net_salary);
}
}
Wdym wrong
The assignment thing marks it wrong?
yes
Oh
I guess you could do it 4, 5 ,6
You'll just need to use some math operators
Let me read your bottom set of code
so far i did this
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.println("Please enter the time you left on Monday: ");
int Monday = input.nextInt();
System.out.println("Please enter the time you left on Tuesday: ");
int Tuesday = input.nextInt();
System.out.println("Please enter the time you left on Wednesday: ");
int Wednesday = input.nextInt();
System.out.println("Please enter the time you left on Thursday: ");
int Thursday = input.nextInt();
System.out.println("Please enter the time you left on Friday: ");
int Friday = input.nextInt();
int payday = Monday, Tuesday, Wednesday, Thursday, Friday;
the correct version
but i don't know how to continue
I got an idea!
Add everything in payday, not comma it
9-4 is a 7 hour shift. Times five days
He should be working 35 hours
So anything over 35 hours should be marked as overtime
correct
So I would make payday (which totals your hours) addition. And then, make another variable called overtime
overtime will be payday-35
Then when you compute salary, do (payday*7)+(overtime*3.5)
That is the simplest way I can think to do it
let me try it
As for your functions that actually calculate how many hours were worked, use a for loop
i can't use a loop
...
the doctor won't accept it
yes
The comp sci kids at my college are already almost done making a full application already and you guys are still not doing loops ðŸ˜
That is odd
this is my 4th week in the univ so yeah..
any suggestion on what I should use instead of the loop?
Ah ok
Umm a lot of if statements
Nested ones
if (Monday == 4) {
int monday_pay = 49;
} else if (Monday == 5) {
int monday_pay = 56;
} else if (Monday == 6) {
int monday_pay = 63;
} else if (Monday == 7) {
int monday_pay = 70;
}
and so on
Just copy paste it and replace the Mondays with the other days
but what if the user adds a number less then 4
How about switch case?
The assignment says they cannot leave before 4
So dw about less
Ohhh switch is good
can't use that
Damn
didn't learn it yet
''' import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.println("Please enter the time you left on Monday: ");
int Monday = input.nextInt();
System.out.println("Please enter the time you left on Tuesday: ");
int Tuesday = input.nextInt();
System.out.println("Please enter the time you left on Wednesday: ");
int Wednesday = input.nextInt();
System.out.println("Please enter the time you left on Thursday: ");
int Thursday = input.nextInt();
System.out.println("Please enter the time you left on Friday: ");
int Friday = input.nextInt();
int payday = Monday + Tuesday +Wednesday + Thursday + Friday;
int overtime = payday-35 :
int salary = (payday7)+(overtime3.5)
System.out.println("Your total weekly salary is " + weekly_payment);
}
'''
so far this is correct?
So lot of if else statements then
put a * in between payday and 7. Same with the overtime one
Oh right. Do `tt` with the graves
yeah
It removes formatting
''' import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.println("Please enter the time you left on Monday: ");
int Monday = input.nextInt();
System.out.println("Please enter the time you left on Tuesday: ");
int Tuesday = input.nextInt();
System.out.println("Please enter the time you left on Wednesday: ");
int Wednesday = input.nextInt();
System.out.println("Please enter the time you left on Thursday: ");
int Thursday = input.nextInt();
System.out.println("Please enter the time you left on Friday: ");
int Friday = input.nextInt();
int payday = Monday + Tuesday +Wednesday + Thursday + Friday;
int overtime = payday-35 :
int salary = (payday*7)+(overtime*3.5)
System.out.println("Your total weekly salary is " + weekly_payment);
}
'''
Word
Welll payday technically will need to add MondayPay or whatever your variable will be
payday should be adding up your hours worked once you compute that
monday_pay + tuesday_pay +... or whatever
alright
Once you get that corrected and your if statements in there, it should run
Unlike my banking software I am trying to code ðŸ˜
ah nice
''' import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
int Monday_pay = 0;
double Tuesday_pay = 0;
double Wednesday_pay = 0;
int Thursday_pay = 0;
int Friday_pay= 0;
System.out.println("Please enter the time you left on Monday: ");
int Monday = input.nextInt();
System.out.println("Please enter the time you left on Tuesday: ");
int Tuesday = input.nextInt();
System.out.println("Please enter the time you left on Wednesday: ");
int Wednesday = input.nextInt();
System.out.println("Please enter the time you left on Thursday: '''
'''");
int Thursday = input.nextInt();
System.out.println("Please enter the time you left on Friday: ");
int Friday = input.nextInt();
int payday = Monday_pay+ Tuesday_pay +Wednesday_pay + Thursday_pay + Friday_pay;
int overtime = payday-35;
int salary = (payday7)+(overtime3.5);
if (Monday == 4) {
int monday_pay = 49;
} else if (Monday == 5) {
int Monday_pay = 56;
} else if (Monday == 6) {
int Monday_pay = 63;
} else if (Monday == 7) {
int Monday_pay = 70;
}
if (Tuesday == 4) {
int tuesday_pay = 49;
} else if (Tuesday == 5) {
int Tuesday_pay = 56;
} else if (Tuesday == 6) {
int Tuesday_pay = 63;
} else if (Tuesday == 7) {
int Tuesday_pay = 70;
}
if (Wednesday == 4) {
int Wednesday_pay = 49;
} else if (Wednesday == 5) {
int Wednesday_pay = 56;
} else if (Wednesday == 6) {
int Wednesday_pay = 63;
} else if (Wednesday == 7) {
int Wednesday_pay = 70;
}
if (Thursday == 4) {
int Thursday_pay = 49;
} else if (Thursday == 5) {
int Thursday_pay = 56;
} else if (Thursday == 6) {
int Thursday_pay = 63;
} else if (Thursday == 7) {
int Thursday_pay = 70;
}
if (Thursday == 4) {
int Thursday_pay = 49;
} else if (Thursday == 5) {
int Friday_pay = 56;
} else if (Thursday == 6) {
int Friday_pay = 63;
} else if (Thursday == 7) {
int Friday_pay = 70;
}
System.out.println("Your total weekly salary is " + payday);'''
what did i do wrong?