/****************************/
/* 台形の面積の計算 */
/* coded by Y.Suganuma */
/****************************/
import java.io.*;
public class Test {
public static void main(String args[])
{
double t1, t2, h, men;
t1 = 3.5;
t2 = 1.0;
h = 0.7;
men = 0.5 * h * (t1 + t2);
System.out.println("面積=" + men);
}
}
/****************************/
/* 円周と面積の計算 */
/* coded by Y.Suganuma */
/****************************/
import java.io.*;
public class Test {
public static void main(String args[]) throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
double r, ens, men, pi;
/*
πの値
*/
pi = 3.141592654;
/*
半径の読込
*/
System.out.print("円の半径は? ");
r = Double.parseDouble(in.readLine());
/*
円周と面積の計算
*/
ens = 2.0 * pi * r;
men = pi * r * r;
/*
出力
*/
System.out.println("円周=" + ens + " 面積=" + men);
}
}
/****************************/
/* 式の値の計算 */
/* coded by Y.Suganuma */
/****************************/
import java.io.*;
public class Test {
public static void main(String args[]) throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
double s1, s2, x, x1;
/*
xの読込
*/
System.out.print("xは? ");
x = Double.parseDouble(in.readLine());
/*
式の計算
*/
x1 = x + 3.0;
s1 = x * x * x + 3.0 * x * x + 2.0;
s2 = x1 * x1 / 3.0 + 5.0;
/*
出力
*/
System.out.println("式1=" + s1 + " 式2=" + s2);
}
}
/****************************/
/* 商と余り */
/* coded by Y.Suganuma */
/****************************/
import java.io.*;
public class Test {
public static void main(String args[]) throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n1, n2, sho, amari;
/*
データの読込
*/
System.out.print("最初の整数を入力して下さい ");
n1 = Integer.parseInt(in.readLine());
System.out.print("2番目の整数を入力して下さい ");
n2 = Integer.parseInt(in.readLine());
/*
計算
*/
sho = n1 / n2;
amari = n1 % n2;
/*
出力
*/
System.out.println("商=" + sho + " 余り=" + amari);
}
}
/****************************/
/* 釣り銭の計算 */
/* coded by Y.Suganuma */
/****************************/
import java.io.*;
public class Test {
public static void main(String args[]) throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int kippu, turi, money, i500, i100, i50, i10;
/*
切符の値段の読込
*/
System.out.print("切符の値段は? ");
kippu = Integer.parseInt(in.readLine());
/*
釣り銭の額
*/
turi = 1000 - kippu;
money = turi;
/*
釣り銭の内訳の計算
500円
*/
i500 = money / 500;
money = money - 500 * i500;
/*
100円
*/
i100 = money / 100;
money = money - 100 * i100;
/*
50円
*/
i50 = money / 50;
money = money - 50 * i50;
/*
10円
*/
i10 = money / 10;
/*
結果の出力
*/
System.out.println("釣り銭 " + turi);
System.out.println("500円 " + i500 + " 100円 " + i100 + " 50円 " + i50 + " 10円 " + i10);
}
}
/****************************/
/* 消費税の計算 */
/* coded by Y.Suganuma */
/****************************/
import java.io.*;
public class Test {
public static void main(String args[]) throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int nedan0, nedan1, nedan2, nedan3;
/*
値段の入力
*/
System.out.print("商品の値段は? ");
nedan0 = Integer.parseInt(in.readLine());
nedan0 = nedan0 * 103;
/*
切り捨て
*/
nedan1 = nedan0 / 100;
/*
切り上げ
*/
nedan2 = (nedan0 + 99) / 100;
/*
4捨5入
*/
nedan3 = (nedan0 + 50) / 100;
/*
出力
*/
System.out.println("切り捨て " + nedan1 + " 切り上げ " + nedan2 + " 4捨5入 " + nedan3);
}
}
| 菅沼ホーム | 演習解答例目次 | 本文目次 | 付録 | 索引 |