AcWing 611. 简单计算 (Java版和C++版) 题解
原题链接
简单
作者:
林小鹿
,
2020-10-24 15:29:55
,
所有人可见
,
阅读 485
C++ 代码
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
double n1, s1, p1;
double n2, s2, p2;
cin >> n1 >> s1 >> p1;
cin >> n2 >> s2 >> p2;
printf("VALOR A PAGAR: R$ %.2lf\n", s1 * p1 + s2 * p2);
return 0;
}
Java 代码
import java.util.Scanner;
import java.text.DecimalFormat;
public class Main
{
public static void main(String[] args)
{
Scanner cin=new Scanner(System.in);
int n1=cin.nextInt();
int s1=cin.nextInt();
double p1=cin.nextDouble();
int n2=cin.nextInt();
int s2=cin.nextInt();
double p2=cin.nextDouble();
double m=p1*s1+p2*s2;
DecimalFormat df=new DecimalFormat("0.00");
System.out.println("VALOR A PAGAR: R$ "+df.format(m));
}
}