Exercise 4: Write a program (Lab8_ex4_ld.py) that generates a random even positive integer less than 10 and displays, using asterisks, a filled diamond. For example, if the generated length is 4, the program should display a filled diamond like the one below. Sample Run for Exercise 4
Q: compare loans with various interest rates) Write a programthat lets the user enter the loan amount…
A: By given problem, it is to be desired to display the user different loan amounts according to the…
Q: Write a program that uses loops to calculate the number of times each possible outcome (sum) occurs.…
A: we need to create two files for question 1 and question 2 For 1st question we need to return 2…
Q: The coding language is python The code in there may or not be correct I was playing around with it…
A: PROGRAM: # The user in prompted for input and stored in userInput userInput = str(input("Enter the…
Q: Write a loop that sets each array element to the sum of itself and the next element, except for the…
A: Completing the given C++ program so, that it can follow the given rubrics:Firstly, displaying a…
Q: Add a while loop to the Imperial BMI procedure below. def BMIImperial(height, weight, bmiList,…
A: First Step is declare bmiList and Category list and pass height, weight, bmiList and Category in the…
Q: Write a program that takes 10 numbers from user, then prints first largest and second largest…
A: The programming language is not mentioned in the question so code will be created in C language.…
Q: Subtract each element in origList with the corresponding value in offsetAmount. Print each…
A: The answr is given below:-
Q: Write the following methodthat tests whether the array has four consecutive numbers with the same…
A: To perform the given task, the coding will involve two parts - 1. main() method 2.…
Q: Instructions: Write a program that creates an ArrayList of Strings. Let the user type in a sentence…
A: Step-1: StartStep-2: Declare a variable sentence and take input from userStep-3: Declare a array…
Q: Write a test program that prompts the user to enter two 3 * 3 arrays of integers and displays…
A: I have provided java code with output in step 2.
Q: Given the following arrays: String days[]={"Monday","Tuesday","Wednesday","Thursday","Friday"};…
A: According to the Question below the solution: Output:
Q: Write a program , that allows the user to enter an array of elements (integers) then sort these…
A: Since you haven't specified the programming language to be used, the code provided is in C++. You…
Q: A positive integer greater than 1 is said to be prime if it has no divisors other than 1 and itself.…
A: Here, Code instruction is given.
Q: Initialize a variable for the row, and set it to zero. Then, create a for loop from 0 to the total…
A: public static int[] oneMonthGenerator(double longitute, double latitude, int month, double[][]…
Q: *please help in java* Array testGrades contains NUM_VALS test scores. Write a for loop that sets…
A: Step 1 : assign sumExtra = 0 Step 2 : Make for loop till testGrades.length Step 3 : check for values…
Q: Declare an integer and an array of doubles called pointValues The array can hold 110 doubles Ask the…
A: Logic:- declare an array of size 110, n Read value of n from user. Iterate from i=0 to i<n…
Q: The two-dimensional arrays m1 and m2 are identical if theyhave the same contents. Write a method…
A: Below is the implementation of the given function to determine whether the two arrays are identical…
Q: Declare an array called rainbowColors using an initializer list. The colors of the rainbow are red,…
A:
Q: Q2) Write a method that counts the occurrences of each capital character in a string. The method…
A: public class CountUpper { public static void main(String[] args) { String str =…
Q: void foo (const char* s) { const int* p = (int*) (s int i-3; while(i){ printf("%c", *C(char %3D p++;
A: The explanation is in the following step.
Q: In the composer array, create a statement that copies the string "Beethoven."
A: STATEMENT: This statement copies the string Beethoven into the composer array. stripy is the…
Q: nly for-loops, if statements, and arrays Write a program in java that uses that creates a 30-element…
A: Required: Write a program in java that uses that creates a 30-element array of random integers to…
Q: Write a program that will help a Little League coach keep track of the players on the team. Use an…
A: Use an infinite loop to display various options and specify a condition to quit from loop when user…
Q: Write a program that prints the ordinal for a random integer from 20 to 100, inclusive. Example…
A: I have first of all taken two numbers num1 and num2 to store 20 and 100. Next, I have used…
Q: 1- write the removeLast function which removes the last digit from a given number, if the number…
A: PROGRAM EXPLANATION(C++): Include the header file. Define the remove last function, this function…
Q: Write a loop that subtracts 1 from each element in lowerScores. If the element was already 0 or…
A: Conditional statement: The "if-else" is called a conditional statement. The condition is checked…
Q: public static int] dateToArray(String date) - Converts a date in a String to an int], and returns…
A: method for above : public static int[] dateToArray(String date) { String[] temp =…
Q: In computational geometry, often you need to find the rightmost lowest point in a set of points.…
A: Lets see the solution.
Q: Read your student number on the command line when you call the program executab Example: testq1.exe…
A: It is defined as the mother language of all the modern programming languages because most of the…
Q: Exercise 4: Write a program (Lab8_ex4_ld.py) that generates a random even positive integer less than…
A: code :-- # for genrate random module import random# genrate random even number between 0 to 10…
Q: Write a program with java that takes 10 numbers from user, then prints first largest and second…
A: Coded using Java.
Q: Create a random number generator for a game in which the user wants the generate 10 random numbers…
A: Write a C++ program to generate 10 random numbers in the range [1,26] and display them along with…
Q: Write a program that generates 10 random numbers (0~99). Save the numbers into arraylnt and…
A: To do: write a program
Q: Add a while loop to the BMI prcoedure below.
A: The given is a snippet of Python code where a function BMIImperial takes some parameters and print…
Q: ODE SHOULD BE IN JAVA WITH ARRAYS AND LOOPS AND STUFFS!! Write an application that allows a user to…
A: Write an application that allows a user to enter the names and birthdates of up to 10 friends.…
Q: Geometric Progression Printer As you might recall, a Geometric Progression (or GP) is a sequence of…
A: ALGORITHM:- 1. Take input for the a1, r and the number of terms to generate in the gp. 2. Print the…
Q: Given an array that contains names of some colors, write a program that picks a color randomly from…
A: Given: An array that contains names of some colors, string colors[] = {“Green”, “Blue”, “Red”,…
Q: age/plot an gif to this code. This is a brownian motion python code here it is code import numpy…
A: It is defined as a powerful general-purpose programming language. It is used in web development,…
Q: Lef counting aeries (n): he Champernowne word 1234567891011121314151617181920212223., also kno…
A: Algorithm Step1: In python create a function pass the parameter n to that function Step2: read the…
Q: Here is the assignment Write a program that prints the multiplication table but inserts a randomly…
A: Program: #include <stdlib.h> #include <iostream>#include <iomanip>using namespace…
Q: Write a program that calculates your final grade. The program prompts the user to enter 4 grades and…
A: The program that uses arrays and loop statement. Declare an array grade of size 4. Then read four…
Q: 1-Write a method that returns m(i) for a given i values 2 + m(i) 2-Write a test program that reads a…
A: C++ is an object oriented programming language which gives a clear structure to program and allows…
Q: What is the output of the following?
A: Before going to the solution I want to explain the forEach loop. For each entry in an array,…
Q: Write a program that displays the roman numeral equivalent of any decimal number between 1 and 20…
A: Given: Write a program that displays the roman numeral equivalent of any decimal number between 1…
Q: How to modify this code so when the user inputs a sentence and that sentence has a persons initials…
A: - We need a modification in the code provided.
Q: In computational geometry, often you need to find the rightmost lowest point in a set of points.…
A: Given program allow user to enter the coordinates of six points and display the rightmost lowest…
Q: *in java* Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements…
A: Given: *in java* Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate…
Step by step
Solved in 4 steps with 3 images
- Write a program that displays the pattern show in the* sample executable.** Type of loop-> your favorite (you must use a pair of* nested loops)* Hints:* 1) Use variables that increments* 2) When running the sample, use values between 61 and* 76 for the number of columns, values between 16 and* 21 the number of rows* 3) Start with a rectangular array of "X" then figure out* how to create one of the upward lines and then the* backwards lines and then both lines*Java Write an application that allows a user to enter the names and birthdates of up to 10 friends. Continue to prompt the user for names and birthdates until the user enters the sentinel value ZZZ for a name or has entered 10 names, whichever comes first. When the user is finished entering names, produce a count of how many names were entered, and then display the names. In a loop, continuously ask the user to type one of the names and display the corresponding birthdate or "Sorry, no entry for name" if the name has not been previously entered. The loop continues until the user enters ZZZ for a name.*in java* Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp = {90, 92, 94, 95}, print:90, 92, 94, 95 Your code's output should end with the last element, without a subsequent comma, space, or newline. import java.util.Scanner; public class PrintWithComma {public static void main (String [] args) {Scanner scnr = new Scanner(System.in);final int NUM_VALS = 4;int[] hourlyTemp = new int[NUM_VALS];int i; for (i = 0; i < hourlyTemp.length; ++i) {hourlyTemp[i] = scnr.nextInt();} /* Your solution goes here */ System.out.println("");}}
- a and b are int variables containing values, and a < b.Write a for loop that prints all odd numbers from a to b (both inclusive).(Example: if a=25, b=82, then it will print 25 27 29 .... 79 81)Write only the for loop with its block, nothing else. with javaCHALLENGE ACTIVITY 8.3.3: Hourly temperature reporting. Write a loop to print all elements in hourly_temperature. Separate elements with a -> surrounded by spaces.Sample output for the given program with input: '90 92 94 95'90 -> 92 -> 94 -> 95 Note: 95 is followed by a space, then a newline. Use Python, please.In java, please read the text file as array. Then, replace the null with 0 and calculate the sum of the new students in ABC University.Example of text file: (university,year,total_students,new_students,new_staff,ABC, 2000, 3457, , ,ABC, 2001, 3675,218, ,EFG, 2000, 2389,602, ,EFG, 2001, 2785,396, 65,)
- compare loans with various interest rates) Write a programthat lets the user enter the loan amount and loan period in number of years anddisplays the monthly and total payments for each interest rate starting from 5% to10%, with an increment of 1/4. Here is a sample run: Loan Amount: 10000Number of Years: 5Interest Rate Monthly Payment Total Payment5.000% 188.71 11322.745.250% 189.86 11391.595.500% 191.01 11460.70...9.750% 211.24 12674.5510.000% 212.47 12748.23Write a program that creates and initializes an array with the following four values: 2.3, 4.5, 8.0, and 2.1. Use a for loop to print the array elements and then use a for loop to print the array elements in reverse order. Using java programmingWrite a program called StudentTable that prints the below table. Use only print() or printf(). DO NOT use println(). ////////////////////\\\\\\\\\\\\\\\\\\\\=============Student Points=============\\\\\\\\\\\\\\\\\\\\////////////////////Name Lab Bonus Total ---- --- ----- -----Joe C 7 50.5William B 8 58.2Mary Sue G 10 49.91) Use \\ to print a single \2) Use \n to go to next line3) Use left justify %– each for Name, Lab, Bonus, Total4) Use width size of 10 (%10) each for Name, Lab, Bonus, Total5) Use %s for String (Joe, William, Mary Sue), %c for char (C, B, G), %d for int (7, 8, 10), %f for double (50.5, 58.2, 49.9)
- In python The text file “studentMarks.txt” has been provided for you. Each line contains the Last Name, First Name and 8 marks separated by spaces of a single student. For each student in the file, adjust the file to include the average of their top 6 marks, rounded to 1 decimal place, at the end of the line. For example, in the file, the line may say: Mars, Bruno 82 82 85 94 65 79 81 90 Afterwards, it should be updated to say: Mars, Bruno 82 82 85 94 65 79 81 90 Top6Avg: 85.7 Your program must define a function to determine the average of the top 6 marks. You may define more functions as needed for your program.In programming language Java, make a programm that scans an array of numbers and then checks which numbers have ONLY one digit 7. For example: we input numbers 23, 143, 98, 2373, 77, 97, 7001. And it displays these numbers: 2373, 97, 7001. (Doesn't display 77 because it has 2 sevens).Write a program , that allows the user to enter an array of elements (integers) then sort these elements in ascending. Hint: first define the array, then loop to enter the elements of the array, and finally use the usual sorting code.