Description
Hand in: A student with number 20180000001 should hand in a file named 20180000001.c for this homework and compress it into a .zip file.
New Type Coronavirus (Covid-19) entered our lives and unfortunately almost brought our lives to a halt! The whole world is trying to fight this virus and there are hundreds of news about it every day. We want to develop a program to follow these news and to find confidential information in the news.
Please note that the main function of this program will consist only of calling the menu () function.
Part 1. [30pts]
Every day, 4 reliable and encrypted news texts are presented to the heads of state selected from thousands of Covid-19 related news. (Selected news of today is in the news folder.) The first line of news texts always includes the title of the news. The other lines are the content of the news text.
• First of all, you should list the headlines of news texts to produce the following output.
• Then, you should print the menu containing the actions that can be performed on the screen.
• If the user chooses the option ‘a’, you should ask which news text you want to read and then print the news text on the screen depending on that choice. After the news text is displayed, the user should be asked if he wants to continue reading. If it wants to continue, the initial menu should be displayed, otherwise the program should be finished.
Assume that the size of the text in the text files will be a maximum of 500 characters.
You should perform all selection operations within a menu () function, but for all other operations that should be done depending on these selections, you should design the functions whose prototype is given below.
void menu()
to read the news from the folder:
[This function reads the entire news text when the value of is_Only_title is 0, and only the title of the news text when 1 arrives.]
void read_news(char buffer[500], char file_path[10], int is_Only_Title)
Part 2. [40 Points]
We also expect this program to keep track of what was previously read. You will need to use this information in both the ‘a’ option and the ‘b’ option.
If the user wants to read a previously read news in ‘a’ option, ‘This news has been read before. Do you want to read it again? ‘ You should warn him/her with the message. And if he/she wants to read it, you should bring that news text back to the screen. If he/she does not want to read, ‘Would you like to continue?’ If you want to continue, you should show the start screen again on the screen. If he doesn’t want to continue, ‘Good Bye!’ You can end the program with the message.
If the user chooses the option ‘b’, you should print the list of news read this time on the screen as shown in the image below.
When the program is opened and closed, it should be kept in a file such as a database, so that the information of the readers are not lost.
to append a character to the file:
void append_file(char* file_path, char c)
When the reader reads the news and wants to read it at different times, you should make sure that it is not added once again to the news list read!
Part 3. [30pts]
Finally, you are expected to decrypt the passwords in the texts. Each news text has a ‘#’ sign placed at random points and a number next to it. These numbers are your magic numbers.
The process described below with your magic numbers will provide you with a variety of information.
()
Let and
The hidden number from the 1st text file will always represent the number of tests performed.
The hidden number from the 2nd text will always represent the number of sick people.
The hidden number from the 3rd text will always represent the number of deaths.
The hidden number from the 4th text will always represent the expected number of sick people.
For reading the magic numbers :
void read_magic_numbers(char buffer_magic[10], char buffer_news[500])
For calculating the f(x) function : double f_func(int x)
For calculating the g(f(x)) function :
double g_func(double f(int x), int a)
General Rules:
1. Obey and don’t broke the function prototypes that are shown on each part, otherwise, you will get zero from the related part.
3. Note that if any part of your program is not working as expected, then you can get zero from the related part, even it’s working in some way.
4. Upload your .zip file on to Moodle to deliver your homework. The zip file must consist of one .c file that contains your solutions. Name format can be found on the top of this homework sheet.
5. You can ask any question about the homework by sending an email to bbuluz@gtu.edu.tr .
Reviews
There are no reviews yet.