C编程中的游轮成本问题 [英] Cruise ship cost problem in C programming

查看:73
本文介绍了C编程中的游轮成本问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是C编程的新手,我绝对难以解决作业问题,只需要一些关于如何解决问题的指示



游轮船舶提供以下套餐5天/ 4晚游轮和住宿



套餐价格

1.房间仅$ 1000.00

2.房间加餐费$ 1000.00 + $ 200.00每个人共用房间

(最多3个)



折扣详情(仅供参考)套餐2)

- 如果只有一个住客是17或以下,则需要50.00美元

- 如果至少有两名住客是17岁或以下,则需要80.00美元



写一个程序询问用户以下信息



1.包装类型(R:仅限房间和M:房间加上餐费)

2.共享房间的人数和他们的年龄



你可以假设所有nu的用户输入merical数据以整数形式输入并且大于零。根据这些信息,程序应计算并显示包装成本如下:

输出:您的成本为$ xxxx.xx





这是一张更清晰的问题图片:



[ ^ ]







谢谢!



我是什么尝试过:



我试过这样做,以便scanf函数读取R或M的用户输入,并创建2个if语句,分别应用于每个输入的公式,但说实话我相信我的方法是错的,真的需要帮助

Hello I am very new to C programming and am absolutely stumped on a homework problem and just need some pointers on how to go about solving the problem

A cruise ship offers the following packages for 5 day / 4 night cruise and stay

Package Rate
1. Room only $1000.00
2. Room plus Meals $1000.00 + $200.00 for each person sharing the room
(Maximum 3)

Discount details (just for package 2)
-$50.00 if just ONE of the occupants is 17 or under
-$80.00 if at least two of the occupants are 17 or under

write a program to ask the user the following information

1.the package type (R:Room only and M:Room plus Meals)
2.Number of persons who share the room and their ages

you may assume that the user input for all the numerical data is entered as integers and greater than zero. based on this information the program should calculate and display the package cost as below:
output:your cost will be $xxxx.xx


Here is a picture of the problem that is more clear:

[^]



thank you!

What I have tried:

I have tried making it so that a scanf function reads a user input of R or M and created 2 if statements which applied the respective formulas to each input but to be honest I believe my approach is all wrong and really need help

推荐答案

1000.00

2.房间加餐
1000.00
2. Room plus Meals


1000.00 +
1000.00 +


200.00每个人共用房间

(最多3个)



折扣详情(仅适用于套餐2)

-
200.00 for each person sharing the room
(Maximum 3)

Discount details (just for package 2)
-


这篇关于C编程中的游轮成本问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆