I really have no idea where to start. Please only respond if you actually want to help. Not to name names, but some people on here are just rude. Here is the assignment and any advice will be greatly appreciated!
1. Write a program that allows the user to enter a series of positive
floating-point numbers.
2. Store the numbers in a linked list.
3. Allow the user to enter numbers until a negative number is entered. (terminate when a negative # is entered).
4. Next, transverse the list to total the numbers entered, number of nodes, and average to the screen
This is really all I have so far after reading the chapter 3 times.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
struct num_node
{
string pos_nums;
float numbers;
num_node *next;
};
num_node *head_ptr; // pointer to head of linked list
num_node *current_ptr; // pointer to current node
// function prototypes
int get_user_data (string &nums, float &numbers);
void add_node (string &nums, float &numbers);
void move_current_to_end();
void display_list();
void delete_list();
int main()
{
string nums;
float numbers;
if (get_user_data(nums, numbers))
{
head_ptr = new num_node;
head_ptr->pos_nums = nums;
head_ptr->numbers = numbers;
head_ptr->next= NULL;
while (get_user_data(nums, numbers))
{
add_node (nums, numbers);
}
display_list(); // display the countries and population
delete_list(); // free the memory used by the linked list
}
return 0;
}