Knowee
Questions
Features
Study Tools

Write a C program for the following:Riley Residence Hall charges different rates for semester room and board based on the number of meals per day the student wants. The semester rate with no meals is $300. With one meal per day, the rate is $450. With two meals per day, the rate is $520, and with three meals per day, the rate is $590. Store these rates in an array. Write a program that allows a student to enter the number of meals desired per day. Output the semester room and board rate.

Question

Write a C program for the following:Riley Residence Hall charges different rates for semester room and board based on the number of meals per day the student wants. The semester rate with no meals is 300.Withonemealperday,therateis300. With one meal per day, the rate is 450. With two meals per day, the rate is 520,andwiththreemealsperday,therateis520, and with three meals per day, the rate is 590. Store these rates in an array. Write a program that allows a student to enter the number of meals desired per day. Output the semester room and board rate.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a simple C program that does what you asked for:

#include <stdio.h>

int main() {
    int rates[4] = {300, 450, 520, 590};
    int meals;

    printf("Enter the number of meals desired per day (0-3): ");
    scanf("%d", &meals);

    if(meals >= 0 && meals <= 3) {
        printf("The semester room and board rate is: $%d\n", rates[meals]);
    } else {
        printf("Invalid number of meals. Please enter a number between 0 and 3.\n");
    }

    return 0;
}

This program first declares an array rates that stores the rates for 0, 1, 2, and 3 meals per day. It then asks the user to enter the number of meals desired per day and stores this number in the variable meals. If the number of meals is between 0 and 3 (inclusive), it prints the corresponding rate from the rates array. If the number of meals is not between 0 and 3, it prints an error message.

This problem has been solved

Similar Questions

To rent a certain meeting room, a college charges a reservation fee of $42 and an additional fee of $7.30 per hour. The math club wants to spend less than $71.20 on renting the meeting room.What are the possible amounts of time for which they could rent the meeting room?Use t for the number of hours the meeting room is rented, and solve your inequality for t.

Bob's 9th-grade class is renting out a bowling alley for a party. The bowling alley charges a flat rate of $300, plus an additional $4 per student. So far, 25 students have signed up to attend the party, and more students will probably sign up before the deadline next week.Find an expression for f(x), the total number of students who will come to the party if x students sign up between now and the deadline.f(x)=Next, find an expression for g(x), the total cost of the party if x students sign up between now and the deadline.g(x)=If the students split the total cost so that each student at the party pays the same amount, which function tells you how much each student will pay?

Marvin used the Quantitative Reasoning Process to build a budget while he is going to college. He worked hard over the summer and saved $3,212.65 to live on during the next two semesters of school. Marvin will receive a scholarship each semester for $959.90. If he plans to use up all of his savings while at school, how much money can Marvin spend each month, on average, for things like groceries, entertainment, and miscellaneous items? Assume two semesters equals 8 months total. Also assume Marvin has no other expenses than what he has listed here. Scholarship for each Semester: $959.90 Tuition & Books Cost per Semester: $2,200Housing Cost for a two-semester Contract: $1,025 If he has money left, what is the average monthly amount Marvin can afford to spend each month?If he has overspent, what is the average monthly amount Marvin would be in debt each month?(Indicate this amount with a negative sign) (Round your answer to the nearest cent

A meal program accepts online payments by way of credit card. For every payment processed, the meal program charges a 2% fee to the customer in addition to their payment amount.The table below shows payment amounts and the appropriate fees charged.Payment Amount $ $23.50 $64.00 $Fee Charged $0.25 $ $ $1.64Reset Submit

Write a C Program to input electricity unit charges and calculate the total bill according to the following conditions:For the first 50 units Rs. 0.50/unitFor the next 100 units Rs. 0.75/unitFor the next 100 units Rs. 1.20/unitFor units above 250 Rs. 1.50/unitAn additional surcharge of 20% is added to the bill.Input: User input of no of unit usedOutput:  The total bill for the consumed units.

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.