需要帮助替换文字 [英] Need help replacing text

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

问题描述

使用C ++在这里苦苦挣扎,但我发现它同时很有趣。有任何好书或网站可以帮助这个项目吗?


对于以下内容 - 我想用cin和cout语句替换前三个语句,以便可以从用户获取age,salary和distance_to_the_moon的值。这使程序变得灵活,以便每次运行时都使用不同的数字。


#include< iostream.h>

void main(void)

{

int age = 32;

浮动工资= 25000.75;

long distance_to_the_moon = 238857;

cout< < ?员工是? <<年龄<< ?岁了? << endl;

cout<< ?员工赚了? <<工资<< endl;

cout<< ?月亮是? << distance_to_the_moon<<

?离地球几英里? << endl;

}



#评论显示在文件顶部,表示作业编号问题编号和你的名字

#税额是一个常数值.085

#用户从键盘输入成本

#10%的折扣将被声明为常数和给定的成本确定

#一个新的变量将被声明为new_cost,将是成本减去折扣

#税将被计算出来10%的折扣后的new_cost取消了成本

#总数将是new_cost加上税金

#用户将从键盘输入amount_paid

#更改将是amount_paid减去总额

#,成本,折扣,新成本,税金,总额和amount_paid都将以适当的格式打印。


#include< iostream.h>

void main()

{

浮动成本= 15.50; //物品的成本

浮动sales_tax = 0.06; //销售税为6%

浮动金额_paid = 20.00; //买方支付的金额

浮动税,变更金额,总金额; //销售税,买方变更和总账单

税=成本* sales_tax;

总计=成本+税;

更改= amount_paid?总计;

cout<< ?物品成本:$? <<成本<< ?税:$? <<税<<

?\tTotal:$? <<总<< endl;

cout<< ?客户变更:$? <<改变<< endl;

}

解决方案

? <<工资<< endl;

cout<< ?月亮是? << distance_to_the_moon<<

?离地球几英里? << endl;

}



#评论显示在文件顶部,表示作业编号问题编号和你的名字

#税额是一个常数值.085

#用户从键盘输入成本

#10%的折扣将被声明为常数和给定的成本确定

#一个新的变量将被声明为new_cost,将是成本减去折扣

#税将被计算出来10%的折扣后的new_cost取消了成本

#总数将是new_cost加上税金

#用户将从键盘输入amount_paid

#更改将是amount_paid减去总额

#,成本,折扣,新成本,税金,总额和amount_paid都将以适当的格式打印。


#include< iostream.h>

void main()

{

浮动成本= 15.50; //物品的成本

浮动sales_tax = 0.06; //销售税为6%

浮动金额_paid = 20.00; //买方支付的金额

浮动税,变更金额,总金额; //销售税,买方变更和总账单

税=成本* sales_tax;

总计=成本+税;

更改= amount_paid?总计;

cout<< ?项目成本:


? <<成本<< ?税:

? <<税<<

?\tTotal:


Struggling greatly here with C++ but I find it interesting at the same time. Any good books to buy or web sites to help with this program?

For the following - I''m suppose to replace the first three statements with cin and cout statements so that the values for the age, salary, and distance_to_the_moon can be obtained from the user. This make the program flexible so that everytime is is run different numbers are used.

#include <iostream.h>
void main(void)
{
int age = 32;
float salary = 25000.75;
long distance_to_the_moon = 238857;
cout << ?The employee is ? << age << ? years old? << endl;
cout << ?The employee makes $? << salary << endl;
cout << ?The moon is ? << distance_to_the_moon <<
? miles from the earth? << endl;
}

# comments appear at the top of the file indicating the assignment number question number and your name
# the tax amount is a constant value of .085
# the user enters from the keyboard the cost
# a discount of 10% will be declared as a constant and given on the cost that was entered
# a new variable will be declared called new_cost and will be the cost minus the discount
# the tax will be figured out on the new_cost after the discount of 10% is taken off of the cost
# the total will be the new_cost plus the tax
# the user will enter the amount_paid from the keyboard
# the change will be the amount_paid minus the total
# and the cost, discount, new cost, tax, total, and amount_paid will all be printed with appropriate format.

# include <iostream.h>
void main()
{
float cost = 15.50; // The cost of an item
float sales_tax = 0.06; // Sales tax is 6 percent
float amount_paid = 20.00; //The amount the buyer paid
float tax, change, total; // Sales tax, buyer change and total bill
tax = cost * sales_tax;
total = cost + tax;
change =amount_paid ? total;
cout << ?Item Cost: $? << cost << ? Tax: $? << tax <<
?\tTotal: $? << total << endl;
cout << ?Customer change: $? << change << endl;
}

解决方案

? << salary << endl;
cout << ?The moon is ? << distance_to_the_moon <<
? miles from the earth? << endl;
}

# comments appear at the top of the file indicating the assignment number question number and your name
# the tax amount is a constant value of .085
# the user enters from the keyboard the cost
# a discount of 10% will be declared as a constant and given on the cost that was entered
# a new variable will be declared called new_cost and will be the cost minus the discount
# the tax will be figured out on the new_cost after the discount of 10% is taken off of the cost
# the total will be the new_cost plus the tax
# the user will enter the amount_paid from the keyboard
# the change will be the amount_paid minus the total
# and the cost, discount, new cost, tax, total, and amount_paid will all be printed with appropriate format.

# include <iostream.h>
void main()
{
float cost = 15.50; // The cost of an item
float sales_tax = 0.06; // Sales tax is 6 percent
float amount_paid = 20.00; //The amount the buyer paid
float tax, change, total; // Sales tax, buyer change and total bill
tax = cost * sales_tax;
total = cost + tax;
change =amount_paid ? total;
cout << ?Item Cost:


? << cost << ? Tax:


? << tax <<
?\tTotal:


这篇关于需要帮助替换文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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