qiuqiuyaq 2021-09-01 17:23 采纳率: 97.9%
浏览 65
已结题

如何用vs2019编译多源文件的程序,代码如下,我不知道操作的过程能不能解释一下

*

#include "hotel.h" 
 
 
int main(void)
{
   int nights;
   double hotel_rate;
   int code;
 
 
   while ((code = menu()) != QUIT)
   {
      switch(code)
      {
      case 1 : hotel_rate = HOTEL1;
               break;
      case 2 : hotel_rate = HOTEL2;
               break;
      case 3 : hotel_rate = HOTEL3;
               break;
      case 4 : hotel_rate = HOTEL4;
               break;
      default: hotel_rate = 0.0;
               printf("Oops!\n");
               break;
      }
      nights = getnights();
      showprice(hotel_rate, nights);
   }
   printf("Thank you and goodbye.");
   
   return 0;
}



#include <stdio.h>
#include "hotel.h"
int menu(void)
{
    int code, status;
 
 
    printf("\n%s%s\n", STARS, STARS);
    printf("Enter the number of the desired hotel:\n");
    printf("1) Fairfield Arms           2) Hotel Olympic\n");
    printf("3) Chertworthy Plaza        4) The Stockton\n");
    printf("5) quit\n");
    printf("%s%s\n", STARS, STARS);
    while ((status = scanf("%d", &code)) != 1  ||
             (code < 1 || code > 5))
   {
        if (status != 1)
            scanf("%*s");
        printf("Enter an integer from 1 to 5, please.\n");
    }
   
    return code;
}
 
 
int getnights(void)
{
    int nights;
 
 
    printf("How many nights are needed? ");
    while (scanf("%d", &nights) != 1)
    {
        scanf("%*s");
        printf("Please enter an integer, such as 2.\n");
    }
   
    return nights;
}
 
 
void showprice(double rate, int nights)
{
    int n;
    double total = 0.0;
    double factor = 1.0;
 
 
    for (n = 1; n <= nights; n++, factor *= DISCOUNT)
        total += rate * factor;
    printf("The total cost will be $%0.2f.\n", total);
}


#define QUIT       5
#define HOTEL1    80.00
#define HOTEL2   125.00
#define HOTEL3   155.00
#define HOTEL4   200.00
#define DISCOUNT   0.95
#define STARS "**********************************"
 
 
// shows list of choices
int menu(void);
 
 
// returns number of nights desired
int getnights(void);
 
 
// calculates price from rate, nights
// and displays result
void showprice(double rate, int nights);

  • 写回答

1条回答 默认 最新

  • CCodelab 2021-09-01 17:41
    关注

    img
    在解决方案里面,鼠标移到项目名称上,点击右键调出菜单,选择添加->现有项或者新建项,最后点生成就好了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 9月9日
  • 已采纳回答 9月1日
  • 创建了问题 9月1日

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)