C ++问题,请任何人帮忙纠正我的错误 [英] C++ Question ,Please can anyone help out want to correct my mistake

查看:72
本文介绍了C ++问题,请任何人帮忙纠正我的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <iostream>using namespace std;

int main()
{
    cout <<"S = Sales"<< endl;
    cout <<"A = Accounting"<< endl;
    cout <<"E = Engineering!"<< endl;
    cout <<"H = Human Resouces"<< endl;
    cout <<"F = Finance!"<< endl;
    
    char dept;
    cout << "Enter your selection: ";
    cin >> dept;
switch (dept)
    {
        cout<<dept;
       case S:  cout << "Sales\n";  // fall through
       case A:  cout << "Accounting\n"; // fall through
       case E:  cout << "Engineering!\n"; // fall through
       case H:  cout << "Human Resouces\n"; // fall through
       case F:  cout << "Finance!\n";
              break;
     }
   cout << "\n\n";
    return 0;
}



请有人可以帮我解决这个问题

编写一个C ++程序,该程序接收5个孩子的输入,并在一个循环中打印其老师的姓名. (老师的名字是虚构的.所以请给你自己的名字).

10.编写程序以显示以下菜单:

•S –销售
•A –会计
•E –工程
•H –人力资源
•F –财务
1.根据用户的选择,显示部门名称.
•提示:请使用Switch…案例.

[edit]不必要的代码块已删除[/edit]



please can someone help me out with this

Write a C++ program that receives input for 5 children and prints the names of their teacher inside a loop. (Teachers names are fictitious. So give your own name).

10. Write a program to display the following menu:

• S – Sales
• A – Accounting
• E – Engineering
• H – Human Resource
• F – Finance
1. Based on the user’s selection, display the department name.
• Hint : use Switch…case.

[edit]unnecesary code block removed[/edit]

推荐答案

查看您的
Review your switch statement[^].

For one each case should have it own break; and also consider adding a default: case for when incorrect input is supplied.


请尝试并尝试过Permalink可以为我提供帮助吗? ,我怎么弄清楚
please i have tried and tried Permalink can you help me out ,how do i figure it out


#include <iostream>

using namespace std;

void Sales()
{
    cout << "Sales";
}
void Accounting()
{
    cout << "Accounting";
}
void Engineering()
{
    cout << "Engineering";
}
void HumanResouces()
{
    cout << "Human Resouces";
}
void Finance()
{
    cout << "Finance";
}
int main()
{
  int dept;

  cout<<"1. Sales\n";
  cout<<"2. Accounting\n";
  cout<<"3. Engineering\n";
  cout<<"4. Human Resouces\n";
  cout<<"5. Finance\n";
  cout<<"6. Exit\n";
  cout<<"Selection: ";
  cin>> dept;
  switch ( dept ) {
  case 1:            // Note the colon, not a semicolon
    Sales();
    break;
  case 2:            // Note the colon, not a semicolon
    Accounting();
    break;
  case 3:            // Note the colon, not a semicolon
    Engineering();
    break;
  case 4:            // Note the colon, not a semicolon
    HumanResouces();
    break;
  case 5:            // Note the colon, not a semicolon
    Finance();
    break;
  case 6:            // Note the colon, not a semicolon
    cout<<"Thank you for your Selecting!\n";
    break;
  default:            // Note the colon, not a semicolon
    cout<<"Error or  bad input, quitting\n";
    break;
  }
  cin.get();
}


这篇关于C ++问题,请任何人帮忙纠正我的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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