How to program print a one-year reminder list

Assignment Help Programming Languages
Reference no: EM13322194

(a) Have the program print an error message and ignore a reminder if the corrsponding day is negative or larger than 31 (using the continue statement)
(b) Allow the user to enter a day, a 24-hout time, and a reminder. The printed reminder list should be sorted first by day, then by time. (The original program allows the user to enter a time, but it's treated as part of the reminder)
(c) Have the program print a one-year reminder list. require the user to enter days in the form month/day.

Here is the given program (I sure hope this pastes correctly):

#include "remind.h"

/* Prints a one-month reminder list */

#include <stdio.h>

#define MAX_REMIND 50 /* maximum number of reminders */

#define MSG_LEN 60 /* max length of reminder message */

int read_line(char str[], int n);

int main(void)

{

char reminders[MAX_REMIND][MSG_LEN+3];

char day_str[3], msg_str[MSG_LEN+1];

int day, i, j, num_remind = 0;

for (;;)

{

if (num_remind == MAX_REMIND)

{

printf("-- No space left --\n");

break;

}

printf("Enter day and reminder: ");

scanf("-", &day);

if (day == 0)

break;

sprintf(day_str, "-", day);

read_line(msg_str, MSG_LEN);

for (i = 0; i < num_remind; i++)

if (strcmp(day_str, reminders[i]) < 0)

break;

for (j = num_remind; j > i; j--)

strcpy(reminders[j], reminders[j-1]);

strcpy(reminders[i], day_str);

strcat(reminders[i], msg_str);

num_remind++;

}

printf("\nDay Reminder\n");

for (i = 0; i < num_remind; i++)

printf(" %s\n", reminders[i]);

return 0;

}

int read_line(char str[], int n)

{

int ch, i = 0;

while ((ch = getchar()) != '\n')

if (i < n)

str[i++] = ch;

str[i] = '\0';

return i;

}

Reference no: EM13322194

Questions Cloud

Fire detection system by security safety : Kuznicki made a contract for the installation of a fire detection system by Security Safety Corp. for $498. The contract was made one night and canceled at 9:00 the next morning.
Write a program that simulates battle between a cat and mice : I have written the program for the below assignment, but I am not getting the correct output. Below is the assignment and the program I have written along with the output I get.
What is length of consecutive wet days that has a occurence : Assuming that the number of days until the next dry day is geometrically distributed, what is the length of consecutive wet days that has a probability of occurence of no more than 0.05
What is probability that one can travel to city three : There are two ways to get from City One to City Three, (a) directly or (b) via City Two. Let A be the event that the road from City One to Three is open. Similarly, B is for City One to Two and C is for City Two to Three.
How to program print a one-year reminder list : Have the program print an error message and ignore a reminder if the corrsponding day is negative or larger than 31 (using the continue statement)
How hard and what direction must you pull on the third rope : One of your friends pulls on a rope with 3 units of force and other pulls on a second rope with 5 units of force, How hard and what direction must you pull
Where will the final image formed by second lens be located : Two 29.0%u2212cm -focal-length converging lenses are placed 14.0cm apart. An object is placed 39.0cm in front of one lens. Where will the final image formed by the second lens be located
Part of an investigative study on supermarket advertising : Three supermarket chains in the New York area each claim to have the lowest overall prices. As part of an investigative study on supermarket advertising the New York Daily Post conducted a study. First, a random sample of nine (9) grocery items was s..
What is the probability that the period is more than 15 min : The van leaves as soon as 6 people have arrived. On average, 24 passengers arrive each hour. What is the probability that the period between bus department is more than 15 minutes.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write program that asks user for two digit number

Write program which asks user for two digit number and then prints English word for that number. Sample run: Enter a two-digit number: 45

  Write program which translate letter grade into number grade

Write program which translates a letter grade into number grade. Letter grades are A, B, C, D, F, possibly followed by + or -.

  Write program to evaluate young worker-s earning

Write down a program to evaluate how much young worker will make before retiring at age 65. Request worker's name, age, and starting salary as input.

  Tools assist novice programmer to generate code

Structured English and gave to a novice programmer who used it to create code? If not, what other tools could be used to assist the novice programmer to generate code?

  Write class called flight which represents airline flight

Draw and implement the class called Flight which represents an airline flight. It must contain instance data which represents airline name (String), flight number (int), and the flight's origin city (String).

  Write gui program as subclass of jframe

Write a GUI program as subclass of JFrame. It should contain the following: Labels At the top (column headings): Meal, Quantity, Cost, At the left: label for each mea.

  Creating session by granting needed privilege

Make sure that Bob can't create objects greater than 512K in size in USERS01 tablespace. And now that user is created, ensure that Bob can create session, by granting needed privilege.

  Write the program to model simple calculator

Write the program to model the simple calculator. Each data line must consist of next operation to be performed from list below and right operand.

  Javascript function to verify fields if cookie is added

JavaScript function has verified that all the required fields have been filled, cookie is added to user's computer. If same user tries to fill out form second time.

  Program prompt teacher to input student number

The program must prompt teacher to input student number. Quiz score for that student will be displayed. Program can prompt for each quiz score.

  Create logic for program which contains housekeeping

Create logic for program in pseudocode or flowchart which contains housekeeping, detail loop, and end-of-job modules, and which computes service charge and the original check amount customers owe for writing bad check.

  Develop computerized pot hole tracking and repair system

Department of public works for city has decided to develop computerized pot hole tracking and repair system. As pot holes are reported to customer service.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd