Hi everyone, Im new to the community and was just wondering if I could get some help :)
I have an assignment where i have to create a program for a shipping company and I was wondering if someone could help me with the coding to assign the sum of a value to my array.
In line 75 after it says Freight Id is: I want to be able to assign the result of case 1 to any number in int freightId and then display it after.
#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdlib>
using namespace std;
double shipcharge(double kg,int miles)
{
double sc;
int p1=(miles/500);
if (miles%500>0)p1++;
if(kg<=2)sc=1.1*p1;
else if(kg<6)sc=2.2*p1;
else if(kg<10)sc=3.7*p1;
else if(kg<=20)sc=4.8*p1;
return sc;
}
int main()
{
int choice; // Menu choice
int freightId [] = { 1721, 1722, 1723, 1724, 1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1743, 1744, 1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753,1754, 1755, 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820 };
int d=0,cnt=0 , miles;
double kg ;
double w;
cout << "\t\tWelcome to FastFreight Company. You can select option from 1-5.\n\n";
cout << "1. Add Freight Order\n";
cout << "2. Update Status\n";
cout << "3. Display Freight Voucher\n";
cout << "4. Display Freight Order\n";
cout << "5. Exit the System\n\n";
cin >> choice;
// Set the numeric ouput formatting.
cout << fixed << showpoint << setprecision(2);
// Respond to the user's menu selection.
switch (choice)
{
case 1:
cout << "Weight of Package: ";
cin >> kg;
w = kg;
if (w <=0 )
{
cout<<"Please enter weight between 0-20.\n";
cin>> kg;
}
else if ( w > 20)
{
cout<<"Please enter weight between 0-20.\n";
cin>> kg;
}
cout << "Distance to be sent:";
cin >> miles;
d = miles;
if (d<10)
{
cout<<"Please enter distance between 10-3000.\n";
cin>> kg;
}
else if(d>3000)
{
cout<<"Please enter distance between 10-3000.\n";
cin>> kg;
}
cout<<"Cost for "<<w<<" kg for "<<d<<" miles is $"<<fixed<<shipcharge(w,d)<<endl;
cout<< "Frieght ID is: "<< <<endl;
cnt++;
break;