#Can anyone help me with my Assignment? It's due in 1 hour

96 messages · Page 1 of 1 (latest)

mint torrent
#

I need more context

#

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

wary storm
#

Sorry I pasted some wrong lines,

mint torrent
#

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

wary storm
mint torrent
#

Right

wary storm
#

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);

}

}

mint torrent
#

Wdym wrong

wary storm
#

if the user adds 1,2 ,3 it won't work

#

it only works if the user adds 4, 5 ,6

mint torrent
#

The assignment thing marks it wrong?

wary storm
mint torrent
#

Oh

wary storm
#

it should work with all numbers

#

not just 4, 5, 6

mint torrent
#

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

wary storm
#

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

mint torrent
#

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

wary storm
#

correct

mint torrent
#

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

wary storm
#

let me try it

mint torrent
#

As for your functions that actually calculate how many hours were worked, use a for loop

wary storm
#

i can't use a loop

mint torrent
#

what

#

bruh

wary storm
#

I'm still studying the basic stuff

#

yup..

mint torrent
#

...

wary storm
#

the doctor won't accept it

mint torrent
#

doctor?

#

College class?

wary storm
#

yes

mint torrent
#

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

wary storm
#

any suggestion on what I should use instead of the loop?

mint torrent
#

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

wary storm
#

but what if the user adds a number less then 4

summer mango
#

How about switch case?

mint torrent
#

The assignment says they cannot leave before 4

#

So dw about less

#

Ohhh switch is good

wary storm
mint torrent
#

Damn

wary storm
#

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?

mint torrent
#

So lot of if else statements then

wary storm
#

thank you guys for helping me

#

thank you so much!

mint torrent
#

put a * in between payday and 7. Same with the overtime one

wary storm
#

i did but discord won't show it

#

i got add ''' ''' next time

mint torrent
#

Oh right. Do `tt` with the graves

wary storm
#

yeah

mint torrent
#

It removes formatting

patent eagleBOT
#
''' 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);

}
'''
mint torrent
#

Word

wary storm
#

so far it's correct?

#

now i gotta add the if statments

mint torrent
#

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

wary storm
#

alright

mint torrent
#

Once you get that corrected and your if statements in there, it should run

#

Unlike my banking software I am trying to code 😭

wary storm
#

lol

#

I can help you with that

#

( in 10 years or so)

mint torrent
#

lmao

#

I am just trying to code minecraft mods/plugins

wary storm
#

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?