我希望该计划能够显示1,2,3年的年度加薪。
用户输入年份 用户输入annualSalary,
然后如果条件为真,则计算如下。
但是,当我运行时,它没有显示我输入的任何给定年份的计算。为什么?我回去几次,试图确定我失踪了什么?
#include "stdafx.h"
#include <iomanip>
#include<iostream>
using namespace std;
int main()
{
double annualSalary = 0;
int year = 0;
double rate3 = 0.03;
double rate4 = 0.04;
double rate5 = 0.05;
double rate6 = 0.06;
double annualRaise = 0;
cout << fixed << setprecision(0);
cout << "enter current year (1 to 3) ";
cin >> year;
cout << "enter annual Salary";
cin >> annualSalary;
if (year = 1)
annualRaise = annualSalary * rate3;
else if
(year = 2)
annualRaise = annualSalary * rate4;
else if
(year = 3)
annualRaise = annualSalary * rate5;
return 0;
}
答案 0 :(得分:2)
您需要添加打印if (year == 1)
{
annualRaise = annualSalary * rate3;
cout << "Salary : " << annualRaise << endl; // output the value
}
else if(year == 2)
{
annualRaise = annualSalary * rate4;
cout << "Salary : " << annualRaise << endl; // output the value
}
else if(year == 3)
{
annualRaise = annualSalary * rate5;
cout << "Salary : " << annualRaise << endl; // output the value
}
system("Pause"); //To be able to keep the console window open
以查看您的工作结果:
Private Sub FWHM_Click(sender As Object, e As EventArgs) Handles FWHM.Click
Dim pythonProcess As New Process()
Dim arg1 As New Integer
arg1 = 1
With pythonProcess
.StartInfo.FileName = "pythonw.exe"
.StartInfo.WorkingDirectory = "C:\Users\...\"
.StartInfo.Arguments = ("HelloWorld.py" & arg1)
.StartInfo.RedirectStandardOutput = True
.StartInfo.UseShellExecute = False
.StartInfo.CreateNoWindow = True
.Start()
End With
End Sub
答案 1 :(得分:1)
使用==
比较=
并添加cout
以查看结果。
if (year == 1)
annualRaise = annualSalary * rate3;
else if
(year == 2)
annualRaise = annualSalary * rate4;
else if
(year == 3)
annualRaise = annualSalary * rate5;
cout << annualRaise;