Write an interactive text based menu interface (using a loop)

Write an interactive text based menu interface (using a loop) that will allow the user to

Enter a task or assignment
Display all of the tasks that are in the file
Find a task by Course
Quit
For each task, you need to keep track of:

Course Name that it is for (e.g., CS162)
Description of the assignment (e.g., Finish Lab 2)
Due date (e.g., 9/26/2009)

Allow the program to keep looping until user wants to quit. When the program starts, it should load the tasks from external file ("tasks.txt") into memory. When user enters the three items of a task, the program needs to read them in, save them in memory and eventually write them to the external data file ("tasks.txt"). The file format could look like: (The ';' is used as a delimiter or field seperator.)

Some Implementation Requirements:

Write at least four functions WITH arguments for this assignment.
Use struct named Task to model task
Use array of structs to model the collection of tasks.
Hint: In this assignment, the description and course name may have multiple words in it. Therefore, you now SHOULD read using the 3 argument version of get.
Watch out. When using the 3 argument version of get you need to make sure to remove the delimiter or newline. Therefore, anytime you read (even a confirmation message), make sure to eat the newline!
Make sure to have a delimiter written between each item in the file – like a newline. This will be important when you read the information back from the file.


This is my code so far:

#include <iostream>

int main()
{
char cname[25],desc[20];
FILE *fp,*fp1;
int dt,ch;
std::cout<<"STORING THE COURSE TASK DETAILS;";
std::cout<<ENTER THE COURSE NAME,DESCRIPTION AND DUE DATE

std::cout<<"ENTER 0 TO QUIT;";
if(ch==0)
{
exit;
}
else
std::cin>>cname>>desc>>dt;
fp=fopen("tasks.txt","w");
std::cout<<fp<<cname<<desc<<dt;
fclose(fp);
fp1=fopen("tasks.txt","r");
std::cin>>cname>>desc>>dt;
std::cout<<cname<<desc<<dt;
fclose(fp1);
}
This is some pretty basic stuff, and to be honest, having people do your homework for you isn't exactly the best idea.

That being said, I can give examples of your implementation requirements :
1
2
3
4
5
6
7
8
9
10
11
12
13
//Write at least four functions WITH arguments for this assignment.
int funcion_1(int a, int b) //the int a and int b in the parenthesis are your arguements
{
    int x = a - b;
    return x;
}

//Use struct named Task to model task
struct Task {string course_name; string assgnmt_desc; string due_date}; //makes a struct that contains all the required informaiton you need to hold

//Use array of structs to model the collection of tasks.
//make an array of a struct
Task tasks[5]; //makes an array of struct Task that can hold up to 5 sets of Task information 


of course these are just examples.

P.S. Next time wrap your code with [.code][./code] (without the .).
Last edited on
Topic archived. No new replies allowed.