Quantcast
Channel: 質問!ITmedia 新着質問(Java/253)
Viewing all articles
Browse latest Browse all 2439

現在学校のjavaの課題電卓を作っています

$
0
0
import java.io.*; class dentaku { public static void main(String[] args)throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); System.out.print("式を入力"); String input = r.readLine(); String sum[] = new String[input.length()]; String number = ""; int s = 0; int goukei =0; char enzan = ' '; for(int i=0; i < input.length(); i++) { //System.out.print(str[i]); //文字列から1文字ずつ抽出 char num = input.charAt(i); if(i == input.length()-1) { sum[s] = number; } else { if(num == '+' || num == '-'|| num == '*'|| num == '/') { //配列sumに代入 sum[s] = number; s++; sum[s] = String.valueOf(num); s++; } else { //変数numberにnumを代入 number = number + num; } } } for(int j=0; j

Viewing all articles
Browse latest Browse all 2439

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>