c++为不符合条件的数据输入创建循环
C++ creating a loop for data entry if does not meet criteria
我已经很长时间没有编程了,我的问题如下:
我希望创建一个循环,如果输入了不正确的工资率,将返回到入口点。我想让它打印出错误通知,如果它不符合标准,否则去你已经符合标准。我也得到了一个错误的数据类型为字符串劳动者没有被定义。智能感知:标识符"劳动者"未定义。我一直在努力工作,如下所示。如有任何指导,不胜感激。
#include "stdafx.h"
#include "stdlib.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cctype>
#include <conio.h>
#include <cstdlib>
#include <cstring>
using namespace std;
int eel;
int hpr;
int kbhit()
void pause()
{
cout << "Press any key to continue....";
while(1)
{
if(kbhit())
{
break;
}
}
}
int _tmain(int argc, _TCHAR* argv[])
{
int eel = Laborer;
int hpr = 0;
while (hpr < 20.00 || hpr >49.99)
{
cout <<"ntt Enter Allowable Pay Rate For The Employee Position."<<endl;
cout <<"nntt =====================================================";
cout <<"ntt The Allowable Pay Rate Is: 20.00 to 49.99 per hour."<<endl;
cout <<"nntt =====================================================";
cout <<"ntt Enter Correct Pay Rate For The Position of "<<eel <<": ";
cin >> hpr;
cout <<"nntt =====================================================";
if (hpr < 20.00 || hpr >49.99){
{
cout<<"nntt XX ERROR! ERROR! XX";
cout<<"nntt YOU HAVE ENTERED AN INCORRECT PAY RATE FOR THE POSITION";
cout<<"nntt PLEASE RE-ENTER THE CORRECT RATE FOR THE POSITION";
}
if (hpr >= 20 && hpr <= 49.99)
{
cout<<"nntt =========================================================";
cout<<"ntt You Entered a Correct Pay Rate for the Position of "<< eel <<endl;
cout<<"ntt Employee Hourly Payroll Rate Is: "<<hpr <<endl;
cout<<"nntt =========================================================";
}
pause(); //To stop program to see if the loop is correct
}
}
不能将未知变量"劳动者"赋值给整数。从你的目标来看…我认为这里需要做的是将int eel = Laborer;
改为string eel = "Laborer";
相关文章:
- C++ 通过输入创建对象
- 如何使用用户输入创建字符串队列?
- 使用用户输入 C++ 创建 N 个不同的向量
- 如何根据用户输入创建和访问多个对象 - C++
- 根据用户输入创建使用C 的图形
- 使用用户输入创建JSON数据库
- 从输入创建最大可能的数字 - 使用 cout 实现问题
- 基于用户输入创建一个字符数组
- 如何使用输入创建函数是C++中的2D数组
- 程序基于用户输入创建多个线程不起作用(cin)
- 从用户输入创建多个类实例
- 基于命令行输入创建 2D 数组
- C++ 如何使用用户输入创建空心框/矩形
- 根据用户输入创建相应的派生类的最佳实践是什么?
- 通过从 CIN 获取运算符的输入创建类>>
- 从C++中的用户输入创建矩阵时出现问题
- 为多个用户输入创建一个结构和调用函数,并通过该结构来显示信息
- 基于用户输入创建n个学生结构
- c++为不符合条件的数据输入创建循环
- 使用来自文件的输入创建变量