Create a Raptor Flowchart that calculates the amount a person would earn over a
ID: 3811640 • Letter: C
Question
Create a Raptor Flowchart that calculates the amount a person would earn over a period of time if his or her salary were one penny the first day, two pennies the second day, and so on doubling each day.
Your program should: 1. Request the number of days. 2. Display a table showing what the salary is for each day 3. Display the total pay
I have done it through Visual Studios but I don't know how to do the flowchart on Raptor. I attached what i did on visual studio if it helps.
#include <iostream>
using namespace std;
int main()
{
int days = 1;
int money = 1.0;
double total = 0.0;
cout << "Enter days worked";
cin >> days;
for (int i = 1; i <= days; i++) {
cout << i << " $" << money / 100.0 << endl;
total += money;
money *= 2;
}
cout << endl << "Total amount =$" << total / 100.0 << endl;
}
Explanation / Answer
public static void main(String[] args) {
int maxDays;
Scanner keyboard = new Scanner(System.in);
System.out.print("Days of work? ");
maxDays = keyboard.nextInt();
while (maxDays < 1)
{
System.out.print("The number of days must be greater than 0. "
+ "Re-enter the number of days: ");
maxDays = keyboard.nextInt();
}
keyboard.close();
System.out.println("Day Pennies Earned");
List<Double> pay = getPay(maxDays, 1);
for (int x = 0; x < pay.size(); x++)
{
System.out.println((x + 1) + " " + pay.get(x));
}
DecimalFormat dollar = new DecimalFormat("#,##0.00");
double totalPay = pay.stream().mapToDouble(Double::doubleValue).sum();
System.out.println("Total pay: $" + dollar.format(totalPay / 100.0));
}
public static List<Double> getPay(int totalNumberOfDays, int pennies) {
List<Double> pay = new ArrayList<>();
pay.add(new Double(1));
int day = 1;
while (day < totalNumberOfDays) {
pay.add(new Double(pennies *= 2));
day++;
}
return pay;
}