Hi! Im new at coding and i wanted to ask some help.
-
The incomplete code bellow doesnt seem to be working as intended. I would be really gratefull to any help. #include #include #include using namespace std; const int N=20;
const char Filename[]= "Shiplist.dat"; struct Ship { unsigned int number; float capacity; char name[50]; }; fstream sp; int menu() { int choice; cout << "\n \t MENU"; cout << "\n 1. Add individual ships"; cout << "\n 2. Add a list of ships"; cout << "\n 3. Print the list of all ships on screen"; cout << "\n 4. Show the ships with the biggest load capacity "; cout << "\n 5. Search ship by name"; cout << "\n 6. Add shipments"; cout << "\n 7. Cancel shipments"; cout << "\n 8. Save ship information"; cout << "\n 9. Add new ship to the list"; cout << "\n 10. Exit"; do { cout << "\n Your choice:"; cin >> choice; } while (choice<1 || choice>10); return choice; } Ship input () { Ship S= { 0 }; cin.ignore(); cout << "\n Enter ship number:"; cin >> S.number; cin.ignore(); cout << "\n Enter the name of the ship:"; cin.getline(S.name,50); cout << "\n Enter the load capacity of the ship:"; cin >> S.capacity; return (S); } int enter (Ship Lib[], int n) { int i, m; do { cout << "\n Enter information for how many ships(max 5 in one go):"; cin >> m; } while(m<0 || m>5); if (n+m < 20) { for (i= n; i
-
The incomplete code bellow doesnt seem to be working as intended. I would be really gratefull to any help. #include #include #include using namespace std; const int N=20;
const char Filename[]= "Shiplist.dat"; struct Ship { unsigned int number; float capacity; char name[50]; }; fstream sp; int menu() { int choice; cout << "\n \t MENU"; cout << "\n 1. Add individual ships"; cout << "\n 2. Add a list of ships"; cout << "\n 3. Print the list of all ships on screen"; cout << "\n 4. Show the ships with the biggest load capacity "; cout << "\n 5. Search ship by name"; cout << "\n 6. Add shipments"; cout << "\n 7. Cancel shipments"; cout << "\n 8. Save ship information"; cout << "\n 9. Add new ship to the list"; cout << "\n 10. Exit"; do { cout << "\n Your choice:"; cin >> choice; } while (choice<1 || choice>10); return choice; } Ship input () { Ship S= { 0 }; cin.ignore(); cout << "\n Enter ship number:"; cin >> S.number; cin.ignore(); cout << "\n Enter the name of the ship:"; cin.getline(S.name,50); cout << "\n Enter the load capacity of the ship:"; cin >> S.capacity; return (S); } int enter (Ship Lib[], int n) { int i, m; do { cout << "\n Enter information for how many ships(max 5 in one go):"; cin >> m; } while(m<0 || m>5); if (n+m < 20) { for (i= n; i
This kind of thing is usually posted as a question. On the menu bar just under the site banner, click on quick answers/Ask a Question. However, "doesn't seem to be working as intended" tells us nothing about what your code is trying to do, and no one is going to waste time trying to guess. You have to provide more details if you want an answer.
Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing. -
The incomplete code bellow doesnt seem to be working as intended. I would be really gratefull to any help. #include #include #include using namespace std; const int N=20;
const char Filename[]= "Shiplist.dat"; struct Ship { unsigned int number; float capacity; char name[50]; }; fstream sp; int menu() { int choice; cout << "\n \t MENU"; cout << "\n 1. Add individual ships"; cout << "\n 2. Add a list of ships"; cout << "\n 3. Print the list of all ships on screen"; cout << "\n 4. Show the ships with the biggest load capacity "; cout << "\n 5. Search ship by name"; cout << "\n 6. Add shipments"; cout << "\n 7. Cancel shipments"; cout << "\n 8. Save ship information"; cout << "\n 9. Add new ship to the list"; cout << "\n 10. Exit"; do { cout << "\n Your choice:"; cin >> choice; } while (choice<1 || choice>10); return choice; } Ship input () { Ship S= { 0 }; cin.ignore(); cout << "\n Enter ship number:"; cin >> S.number; cin.ignore(); cout << "\n Enter the name of the ship:"; cin.getline(S.name,50); cout << "\n Enter the load capacity of the ship:"; cin >> S.capacity; return (S); } int enter (Ship Lib[], int n) { int i, m; do { cout << "\n Enter information for how many ships(max 5 in one go):"; cin >> m; } while(m<0 || m>5); if (n+m < 20) { for (i= n; i
Ship input () {
Ship S= { 0 };
cin.ignore();
cout << "\n Enter ship number:"; cin >> S.number;
cin.ignore();
cout << "\n Enter the name of the ship:"; cin.getline(S.name,50);
cout << "\n Enter the load capacity of the ship:"; cin >> S.capacity;return (S);
}
It will help get a quicker answer if your code is properly indented, and uses the correct <pre> tags as above.
-
The incomplete code bellow doesnt seem to be working as intended. I would be really gratefull to any help. #include #include #include using namespace std; const int N=20;
const char Filename[]= "Shiplist.dat"; struct Ship { unsigned int number; float capacity; char name[50]; }; fstream sp; int menu() { int choice; cout << "\n \t MENU"; cout << "\n 1. Add individual ships"; cout << "\n 2. Add a list of ships"; cout << "\n 3. Print the list of all ships on screen"; cout << "\n 4. Show the ships with the biggest load capacity "; cout << "\n 5. Search ship by name"; cout << "\n 6. Add shipments"; cout << "\n 7. Cancel shipments"; cout << "\n 8. Save ship information"; cout << "\n 9. Add new ship to the list"; cout << "\n 10. Exit"; do { cout << "\n Your choice:"; cin >> choice; } while (choice<1 || choice>10); return choice; } Ship input () { Ship S= { 0 }; cin.ignore(); cout << "\n Enter ship number:"; cin >> S.number; cin.ignore(); cout << "\n Enter the name of the ship:"; cin.getline(S.name,50); cout << "\n Enter the load capacity of the ship:"; cin >> S.capacity; return (S); } int enter (Ship Lib[], int n) { int i, m; do { cout << "\n Enter information for how many ships(max 5 in one go):"; cin >> m; } while(m<0 || m>5); if (n+m < 20) { for (i= n; i
panda08 wrote:
The incomplete code bellow....
If you completed, would it then work?
panda08 wrote:
The incomplete code bellow doesnt seem to be working...
Was it intentional that you failed to explain what it is (not) supposed to do?
panda08 wrote:
...as intended.
What is its intent? The onus is on you to pare down your code to just that which is problematic; not ours to wade through a bunch of code to try and figure out what it is supposed to do and why it is not doing such.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles