{
// 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?
Oh, dude, creating a flowchart for that is like making a peanut butter and jelly sandwich - easy peasy. You just gotta start with a diamond shape for the decision-making process, then add rectangles for the input/output and calculations. Like, you'll have one box for accepting the number, another for calculating the product of the integers, and a final one for printing the result. It's like drawing a map to the land of math!
== == // 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; }
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.
To write a program that prints a text of 4 lines consisting of integer and floating point values, you can use formatted strings in Python. Here's a simple example: int_value = 42 float_value = 3.14 print("Line 1: Integer value is", int_value) print("Line 2: Float value is", float_value) print("Line 3: Sum of values is", int_value + float_value) print("Line 4: Float value to two decimals is {:.2f}".format(float_value)) This code snippet prints four lines, showcasing both integer and floating point values.
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.
The largest denomination of currency the US prints today is the $100 bill.
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?
thomas prints invented prints
Oh, dude, creating a flowchart for that is like making a peanut butter and jelly sandwich - easy peasy. You just gotta start with a diamond shape for the decision-making process, then add rectangles for the input/output and calculations. Like, you'll have one box for accepting the number, another for calculating the product of the integers, and a final one for printing the result. It's like drawing a map to the land of math!
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; }