“Write a program that calculates the amount a person makes over a period of time if his or her salary is one penny the first day, two the next and it continues to double each day. Program should display a table showing the salary for each day and then show the total pay at the end of the period. Output should be in dollars no Pennie’s. “ Pennie’s for pay problem. Assume I know nothing just trying to get this done.
#help with Java
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
“Write a program that calculates the amount a person makes over a period of time if his or her salary is one penny the first day, two the next and it continues to double each day. Program should display a table showing the salary for each day and then show
Here is a simple Java program to calculate the total amount earned over a period of time with the given conditions:
public class SalaryCalculator {
public static void main(String[] args) {
int days = 10; // Change this value to calculate earnings for a different number of days
double totalSalary = 0.01; // Starting salary on the first day
double dailySalary = 0.01;
for (int i = 2; i <= days; i++) {
dailySalary *= 2;
totalSalary += dailySalary;
System.out.println("Day " + i + ": $" + dailySalary);
}
System.out.println("Total salary earned in " + days + " days: $" + totalSalary);
}
}
This program calculates the salary earned each day by doubling the previous day's salary and keeps track of the total amount earned over a specified number of days. You can adjust the days variable in the code to calculate earnings for different periods of time.
Simply compile and run this Java program, and it will output the daily earnings and the total salary earned over the specified number of days.
- AI generated response
Well what do you need help with 🙂 ?
Nvm the ai got me
Wont learn anything that way 😦