⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex1parta.java

📁 Snunuiot are flying as far as you send them... and then they die ha ha ha
💻 JAVA
字号:
import java.util.Scanner;

public class Ex1PartA {
	
	public static void main (String[] args){
		
		Scanner sc = new Scanner(System.in);
		
//		variable declarations:
		int sum,limit, target,a,b,c;
		double fraction;
		
//		reading the values of 'limit' and 'target' from the user:
		System.out.print("Enter the limit: ");
		limit = sc.nextInt();
		System.out.print("Enter the target: ");
		target = sc.nextInt();
		while (target==0){
			System.out.print("Invalid input.\nEnter the target: ");
			target = sc.nextInt();
		}
//		computing and printing the summation of the two numbers:
		sum = limit + target;
		System.out.println("The value of the operation " 
				+ limit+"+" + target + " is " + sum);
		
//		computing and printing the division of 'limit' with 'target':
		fraction = (double)limit / (double)target;
		System.out.println("The value of the operation " + limit + "/"
				+ target + " is " + fraction);

		System.out.println ("----------");

		for (a=0;a<=limit ;a=a+1){
			for (b=0;b<=limit ;b=b+1){
				for (c=0;c<=limit ;c=c+1){
					if ((a+b+c)==target) {
						System.out.println ("a = "+a+",b = "+b+",c = "+c);
					}
				}
			}
		}
		System.out.println ("----------");

	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -