{
// set up our input buffer
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String currentLine;
// store our ints in a list
int smallest = 0;
int largest = 0;
// counter
int numIntsRead = 0;
// force smallest and largest to start as the first proper int entered
while (numIntsRead < 1) {
currentLine = in.readLine();
try {
// convert from string to int
int currentNumber = Integer.parseInt(currentLine);
smallest = currentNumber;
largest = currentNumber;
++numIntsRead;
} catch (final NumberFormatException ex) {
// we go here if the user didn't type in an integer
}
}
// loop until we read all 5 ints
while (numIntsRead < 5) {
currentLine = in.readLine();
try {
// convert from string to int
int currentNumber = Integer.parseInt(currentLine);
if (currentNumber < smallest) {
smallest = currentNumber;
}
if (currentNumber > largest) {
largest = currentNumber;
}
++numIntsRead;
} catch (final NumberFormatException ex) {
// we go here if the user didn't type in an integer
}
}
// display our findings
System.out.println("Smallest:\t" + smallest);
System.out.println("Largest:\t" + largest);
}
final double[] ns = new double[10]; final Random rnd = new Random(System.currentTimeMillis()); // Fill... for (int i = 0; i < ns.length; ++i) { ns[i] = rnd.nextDouble(); } // Get largest/smallest... double largest = Double.MIN_VALUE; double smallest = Double.MAX_VALUE; for (double n : ns) { if (n > largest) { largest = n; } if (n < smallest) { smallest = n; } } // largest and smallest are now the proper values.
#include<stdio.h> main() { int a,b,c,d; // The four integers to be asked printf("Give the first integer: "); //asks for the first integer scanf("%d",&a); // puts the user input in the address of the integer "a" printf("Give the second integer: "); //same explanations scanf("%d",&b); printf("Give the third integer: "); scanf("%d",&c); printf("Give the fourth integer: "); scanf("%d",&d); printf("1. The sum of the four integers is: %d",a+b+c+d); //prints the sum of the four integers given by the user, notice the "a+b+c+d" at the end) printf("2. The sum of the first two numbers minus the sum of the last: %d",a+b-c-d); //prints the second condition by putting the correct operations return 0; //ends the program } I never tested this program though, but i think it would work.
write a program that reads in the size of the side of square and then pints a hollow square of that size out of asterisks and blanks?
== == // Returns number of 7s in num. int numSevens(int num) { int _num = num; int numSevens = 0; while( _num > 0 ) { if( (_num % 10) == 7 ) { ++numSevens; } _num /= 10; } return numSevens; }
// create an BufferedReader from the standard input stream BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String currentLine = ""; int total = 0; int[] ints = new int[5]; // read integers while (total < 5) { // get input System.out.print("Input an integer: "); currentLine = in.readLine(); // parse as integer try { int input = Integer.parseInt(currentLine); ints[total] = input; ++total; } catch (final NumberFormatException ex) { System.out.println("That was not an integer."); } } // print each number for (int i = 0; i < ints.length; ++i) { // get individual digits if (ints[i] == 0) { System.out.println(0); } else { while (ints[i] > 0) { System.out.println(ints[i] % 10); ints[i] /= 10; } } } Note that this prints out the digits in reverse order (2048 will print 8 first and 2 last).
final double[] ns = new double[10]; final Random rnd = new Random(System.currentTimeMillis()); // Fill... for (int i = 0; i < ns.length; ++i) { ns[i] = rnd.nextDouble(); } // Get largest/smallest... double largest = Double.MIN_VALUE; double smallest = Double.MAX_VALUE; for (double n : ns) { if (n > largest) { largest = n; } if (n < smallest) { smallest = n; } } // largest and smallest are now the proper values.
#include<stdio.h> main() { int a,b,c,d; // The four integers to be asked printf("Give the first integer: "); //asks for the first integer scanf("%d",&a); // puts the user input in the address of the integer "a" printf("Give the second integer: "); //same explanations scanf("%d",&b); printf("Give the third integer: "); scanf("%d",&c); printf("Give the fourth integer: "); scanf("%d",&d); printf("1. The sum of the four integers is: %d",a+b+c+d); //prints the sum of the four integers given by the user, notice the "a+b+c+d" at the end) printf("2. The sum of the first two numbers minus the sum of the last: %d",a+b-c-d); //prints the second condition by putting the correct operations return 0; //ends the program } I never tested this program though, but i think it would work.
Here's a simple C program that prompts the user for three decimal numbers, converts them to integers, and prints the trimmed integer values: c Copy code #include int main() { double num1, num2, num3; // Prompt the user for three decimal numbers printf("Enter three decimal numbers: "); scanf("%lf %lf %lf", &num1, &num2, &num3); // Convert and print the trimmed integer values int intNum1 = (int)num1; int intNum2 = (int)num2; int intNum3 = (int)num3; printf("Trimmed integer values: %d, %d, %d\n", intNum1, intNum2, intNum3); return 0; } In this program: We declare three variables num1, num2, and num3 to store the decimal numbers entered by the user. We use printf to prompt the user to enter three decimal numbers. We use scanf to read and store the user's input in the variables num1, num2, and num3. We then convert these decimal numbers to integers by casting them using (int) and store them in intNum1, intNum2, and intNum3. Finally, we use printf again to print the trimmed integer values. Compile and run the program, and it will prompt you for three decimal numbers and print their trimmed integer values as requested.
write a program that reads in the size of the side of square and then pints a hollow square of that size out of asterisks and blanks?
The largest denomination of currency the US prints today is the $100 bill.
thomas prints invented prints
wet prints are those in which fabri is either dyed or printed dry prints are the fancy prints like flock prints, burn out prints.
%p prints a pointer, %x prints an integer. They may be similar, but not the same. Eg.printf ("ptr=%p int=%d\n", main, (int)main);DOS: ptr=0F01:0010 int=10Windows: ptr=:0F010010 int=F010010
public static void main (String args[]) throws IOException { int abc = System.in.read(); }
== == // Returns number of 7s in num. int numSevens(int num) { int _num = num; int numSevens = 0; while( _num > 0 ) { if( (_num % 10) == 7 ) { ++numSevens; } _num /= 10; } return numSevens; }
// create an BufferedReader from the standard input stream BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String currentLine = ""; int total = 0; int[] ints = new int[5]; // read integers while (total < 5) { // get input System.out.print("Input an integer: "); currentLine = in.readLine(); // parse as integer try { int input = Integer.parseInt(currentLine); ints[total] = input; ++total; } catch (final NumberFormatException ex) { System.out.println("That was not an integer."); } } // print each number for (int i = 0; i < ints.length; ++i) { // get individual digits if (ints[i] == 0) { System.out.println(0); } else { while (ints[i] > 0) { System.out.println(ints[i] % 10); ints[i] /= 10; } } } Note that this prints out the digits in reverse order (2048 will print 8 first and 2 last).
when you put your finger prints on the glassthen their is finger prints