Commit 2e67d448acfb4b704dfae3bcd30f951d81a2003f

Authored by Anton Qiu
1 parent 0a334e061f
Exists in master

p4 done

Showing 2 changed files with 33 additions and 0 deletions Side-by-side Diff

No preview for this file type

HW3/rating.c View file @ 2e67d44
  1 +#include <stdbool.h>
  2 +#include <stdio.h>
  3 +
  4 +int main() {
  5 + char rate;
  6 + int age = 0;
  7 + bool suit = false;
  8 +
  9 + printf("Enter the movie rating (G, P, or R): ");
  10 + scanf("%c", &rate);
  11 + printf("How old are you? ");
  12 + scanf("%d", &age);
  13 +
  14 + if (rate == 'G') {
  15 + suit = true;
  16 + }
  17 + else if (rate == 'P' && age >= 13) {
  18 + suit = true;
  19 + }
  20 + else if (rate == 'R' && age >= 17) {
  21 + suit = true;
  22 + }
  23 + else {
  24 + suit = false;
  25 + }
  26 +
  27 + if (suit)
  28 + printf("Suitable movie. Enjoy!\n");
  29 + else
  30 + printf("Unsuitable movie. Enjoy the review!\n");
  31 +
  32 + return 0;
  33 +}