Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

follow these instructions to complete your assignment: 1. write a flowc…

Question

follow these instructions to complete your assignment: 1. write a flowchart and c code for a program that does the following: • asks a user the number of years of employment service • uses an else...if statement to display the following messages • service greater than 25 years - you receive a gold watch • service greater than 15 but less than 25 years - you receive a silver pen • service greater than 5 but less than 15 years - you receive an attractive pin • service between 0 and 5 years - you receive a pat on the back • be sure that you are using a logical operator to include all values. • don’t forget to add curly brackets with each condition. • feel free to use logical operators in the conditions - this is not required. 2. review the output below to check your work

Explanation:

Answer:

Discipline: Natural Science; Sub - field: Computer Science
(1) Flowchart:

  • Start
  • Input number of years of employment service (let's call it years)
  • Decision box: If years > 25
  • Output "You receive a gold watch"
  • End
  • Else - If years > 15 && years < 25
  • Output "You receive a silver pen"
  • End
  • Else - If years > 5 && years < 15
  • Output "You receive an attractive pin"
  • End
  • Else - If years >= 0 && years <= 5
  • Output "You receive a pat on the back"
  • End
  • End

C code:

#include <stdio.h>

int main() {
    int years;
    printf("Enter the number of years of employment service: ");
    scanf("%d", &years);
    if (years > 25) {
        printf("You receive a gold watch
");
    } else if (years > 15 && years < 25) {
        printf("You receive a silver pen
");
    } else if (years > 5 && years < 15) {
        printf("You receive an attractive pin
");
    } else if (years >= 0 && years <= 5) {
        printf("You receive a pat on the back
");
    }
    return 0;
}