The sum of the reciprocals 1 + 1/2 + 1/3 + 1/4 + … is infinite. I’m supposed to write a program that reads in a target and finds the first n such that 1 + 1/2 + 1/3 + … + 1/n > target, but I can’t figure out how to do it. This is where I’m currently at, and the following code just results in an infinite loop. Any help will be greatly appreciated.
Q: Write a program that reads in an integer, N, and computes the first N Pell numbers and outputs them…
A: Below is the required program in C language. Approach of Program: Include necessary header files.…
Q: Write a program that asks the user for a number and writes its decomposition into prime factors: The…
A: The given is a programming assignment where the program is to be written in C++. The user will be…
Q: Write a program that accepts a set of integer numbers. Your program should count the number of even…
A: The question asks to find the total number even present in the sequence and also find the maximum of…
Q: Do it quick I don't have my system right now so i need your help Program to find the sum of…
A: NOTE: As the programming language is not mentioned in the question. So, we have solved this question…
Q: Write an assembly language program that receives a number n from input, and determines if n is prime…
A: Start. Read input from the user. Divide the number n with each possible divisor. If found one then…
Q: Show manual tracing for the following program and find the final output. In the program,…
A: The program given is: #include<stdio.h>int a, b;int func1(float x);void func2(int x, float y);…
Q: def count_and_say(digits): Given a string of digits that is guaranteed to contain only digit…
A: Actually, python is a easiest programming language. It is a dynamically typed programming language.
Q: Write a program that takes an integer 'n' from the user. Prints the following pattern according to…
A: Code using C++ and without the use of arrays is below which takes an 'n' integer from the user.…
Q: Write a python program that will take two inputs from the user. One string with a length greater…
A: The concept in the program is that if the index of the string is divisible by the number then we…
Q: Write a program that reads a list of integers, one per line, until an * is read, then outputs those…
A: logic:- use while True i.e infinite loop. read input() if user_input is * break the…
Q: Make a program that asks for random integers, positive or negative, and sums up all the negative…
A: Coded using C language.
Q: For f(x)=e*cos(3.x³), ƒ(x)=-2xe[3 sin(3 x²)+cos (3 .x³)]. Write a program FullName2.sce that samples…
A: Given: Code on Scilab Plz
Q: Write a python program using while loop to find the sum of the below given series up to n. S=1 /23 +…
A: The problem is about to find the sum of the sequence generated upto a given number of terms.
Q: Write a program that reads a list of integers, one per line, until an * is read, then outputs those…
A: Need to write python program which reads a list of integers, one per line, until an * is read, then…
Q: In Python, write an improved version of the chaos.py program that allows a user to input 2 initial…
A: print("Tis program illustrates a chaotic funstion") x=eval(input("Enter a first number between 1 and…
Q: Write a program to compute the most frequent numbers in vectors ( x ), and ( y ) if x= a*b y=a* c a…
A: Note: The syntactical code in the question is in Matlab, hence answering the code in Matlab. Given…
Q: : by formula (s=a/1-r), and by adding the individual terms until the answer agrees with the formula…
A: Lets see the solution.
Q: • Alternating the signs of reciprocals of powers of any n>1 produces a convergent series: 1 1, 1 1.…
A: #include <stdio.h>#include <string.h>#include <stdlib.h> /// function solve to…
Q: Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's…
A: Program Algorithm-STARTStep 1: Import the essential headers.Step 2: Define the main function.Step 3:…
Q: programming Implement an encoder. When completed, your program should be able to accept a short…
A: The program is written in C Language. Check the program screenshot for the correct indentation.…
Q: Trace this C code: What is the output of the following program segment? (Trace code and show your…
A: //include the header file #include <stdio.h> //definition of the main function int main() {…
Q: Given positive integer num_insects, write a while loop that prints, then doubles, num_insects each…
A: Program code: #get the numbernum_insects = int(input()) #iterate while num_insects <= 100while…
Q: python Write a loop that prints each country's population in country_pop. Sample output with…
A: Actually, python is a easiest programming language. It is a dynamically typed programming language.…
Q: Write a program that reads the width, height and a character from the user, then calculates the…
A: Code import java.util.Scanner;public class Main{ public static void main(String[] args) {…
Q: Your program is to use the brute-force approach in order to find the Answer to Life, the Universe,…
A: Required: In c++ please Your program is to use the brute-force approach in order to find the Answer…
Q: Write a simple program that takes in a numerator and denominator and then computes the GCD for that…
A: import java.util.Scanner;public class Main{ public static void main(String[] args) { Scanner…
Q: We want to represent positive integer n as a sum of addends, where each addends is an integer number…
A: Actually, given information is: We want to represent positive integer n as a sum of addends, where…
Q: Write a C++ program that uses the following for loop: for ( int i = 0; i < e; i++ ) { for ( int j…
A: Logic: e indicates number of rows f indicates number of columns The table represent current row *…
Q: Implement the numerical approximation of √2 using for loop, (conformin places). 2 x₁ = 1 X + 2 X₁…
A: Given :
Q: Write a program that swaps 5th~11th bits in data_a with 25th~31th bits in data_b Your program must…
A: Sample 1: ldr r12, =0x55555555 //Load the mask for only even bits and r1, r12, r0, lsr #1 //r1…
Q: Write a program that accepts a positive integer n. The program should output a cascading triangular…
A: I give the flowchart along with code and output screenshot in C
Q: I need to write a Java program to count the number of muck-free regions in a lagoon. The Lagoon is…
A: Solution int main() { memset(vis,0,sizeof(vis)); memset(q,0,sizeof(q)); memset(g,0,sizeof(g));…
Q: Write a program to calculate the following series by using loop S= (x^0 /0!)+ x^1/1! + x^2/2! + n!…
A: To do: Write a program for the given series
Q: Write a program that reads 3 integers and prints the maximum value among them. (without using max())
A: function main: Start Read num1, num2, num3 if num1 >= num2 and num1 >= num3 then largest =…
Q: Write a loop in python that prints each country's population in country_pop.
A: The given values are stored in dictionary which are stored as key-value pairs and thus we access the…
Q: Given a chess board, your job is to write a program that takes two squares x and y as input and then…
A: Program: #include <bits/stdc++.h> using namespace std; int dx[8]={-2, -2, -1, -1, 1, 1, 2,…
Q: Dreamworld is known for his uniqueness and there are 2 different denomination coins in Dreamworld,…
A: Please find the code below:
Q: Write a program that creates a table for the user's choice of basic math operations (+, -, *, /, and…
A: def addition(): x = getsize() print("\n+ | ",end=' ') for i inrange(1,x+1): print(i,end=' ')…
Q: Write a C++ program: to iteratively compute Fibonacci numbers (named after an Italian…
A: A C++ program to generate fibonacci series using recursion is given below,Program://Declare header…
Q: In PYTHON, write a code that allows the user to input two non-negative number sequences in…
A: the answer is given below:-
Q: For the multiple-choice questions, type your answer into the _highlighted blank (like this)____…
A: Hey, since there are multiple questions posted, we will answer first question. If you want any…
Q: Write an improved version of the chaos . py program from Chapter 1 thatallows a user to input two…
A: Lets see the solution.
Q: Write a program that takes in a positive integer as input, and outputs a string of 1's and O's…
A: I have implemented the given requirements in python as per the specification. The code in python is…
Q: Write a C1500 program that will check if your student number is even (i.e. it is divisible by 2).…
A: #include <stdio.h> int main() { // define student number intstudent_number = 123456789;…
Q: Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's…
A: Since programming language is not specified, we will be answering this question in python.
Q: What would be the output of the following program? Please note that the operation x % 10 (i.e., x…
A: Solution:
Q: Write down a program that will find the summation of all odd frcrors of a number N. N will be input…
A: Below is the required code in C language. Program Approach: Include necessary header files to get…
Q: What is the output for the following pseudocode segment? For your answer list all outputs (not just…
A: Pseudocode is the step by step instructions written in the normal English language that can be…
Q: Write a program that gets a list of integers from input, and outputs non-negative integers in…
A: Here I have taken input from the user and then stored it into the list. Next, I have iterated over…
Q: Write a program that prompts the user to enter the length from the center of a pentagon to a vertex…
A: Program Structure: • Declare double type variables to store side and area of pentagon. • Read…
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images
- Define the method findHighestValue() with a Scanner parameter that reads integers from input until a negative integer is read. The method returns the largest of the integers read. Ex: If the input is 70 65 100 -85 -15 -50, then the output is: 100Note: Negative numbers are less than 0. import java.util.Scanner; public class HighestValueFinder { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int maxVal; maxVal = findHighestValue(scnr); System.out.println(maxVal); }}I need help with creating a Java program described in the image below: CourseInformation.java: import java.util.Scanner; public class CourseInformation { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Course myCourse = new Course(); OfferedCourse myOfferedCourse = new OfferedCourse(); String courseNumber, courseTitle; String oCourseNumber, oCourseTitle, instructorName, location, classTime; courseNumber = scnr.nextLine(); courseTitle = scnr.nextLine(); oCourseNumber = scnr.nextLine(); oCourseTitle = scnr.nextLine(); instructorName = scnr.nextLine(); location = scnr.nextLine(); classTime = scnr.nextLine(); myCourse.setCourseNumber(courseNumber); myCourse.setCourseTitle(courseTitle); myCourse.printInfo(); myOfferedCourse.setCourseNumber(oCourseNumber); myOfferedCourse.setCourseTitle(oCourseTitle); myOfferedCourse.setInstructorName(instructorName);…in java Write code that prints: firstNumber … 2 1Print a newline after each number. Ex: If the input is: 3 the output is: 3 2 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import java.util.Scanner; public class ForLoops { publicstaticvoidmain (String [] args) { intfirstNumber; inti; Scannerinput=newScanner(System.in); firstNumber=input.nextInt(); for () { System.out.println(i); } } }
- Look at the following applet code snippet: 1 import javax.swing.*; 2 import java.awt.*; 3 public class GraphicsTest extends JApplet 4 { 5 public void init() 6 { 7 getContentPane().setBackground(Color.WHITE); 8 } 9 public void paint(Graphics g) 10 { 11 int[] xCoords = {20, 20, 60, 100, 140, 140, 100, 60}; 12 int[] ycoords = {20, 100, 140, 140, 100, 60, 20, 20}; 13 super.paint(g); 14 g.setColor(Color.YELLOW); 15 g.fillPolygon(xCoords, yCoords, 8); 16 g.setColor(color.BLACK); 17 g.setFont(new Font("SansSerif", Font.BOLD, 35)); 18 g.drawString("SLOW", 35, 95); 19 } 20 } How many vertices does the polygon have? Justify your answer.Consider the following Java program. Describe what it does in response to specific operations of the mouse, and how it does it. (You are encouraged to run the program for yourself to test its behavior. Then read through the program carefully to understand how that behavior arises.) import java.awt.event.*;import javax.swing.*;public class MouseWhisperer extends JFrame implements MouseListener { MouseWhisperer() { super("COME CLOSER"); setSize(300,100); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); addMouseListener(this); setVisible(true); } public void mouseClicked(MouseEvent e) { setTitle("OUCH"); } public void mousePressed(MouseEvent e) { setTitle("LET GO"); } public void mouseReleased(MouseEvent e) { setTitle("WHEW"); } public void mouseEntered(MouseEvent e) { setTitle("I SEE YOU"); } public void mouseExited(MouseEvent e) { setTitle("COME CLOSER"); } public static void main(String[] args) { new MouseWhisperer(); }}Please make it run out like the EXPECT PICTURES Don’t use try catch // Step 1: Import Java classes Arrays, Random, and Scanner import java.util.Arrays; import java.util.InputMismatchException; import java.util.Random; import java.util.Scanner; /** * A class to generate a random int array then call static * methods to sort and display the array elements. * * Step 2: Enter your name for @author and today's date for @version * @author * @version */ public class StaticMethodApp { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter an integer: "); // Step 3: While the next input token is not an integer // Read the input token // Display a message // Sample message, assuming the input is Java // Not an integer: "Java" // Display the same promt again…
- hi, why my code when i try to calculate BMI every time the answer equal 0.0 and can't get the right answer? package a;import java.util.*;public class a { public static void main(String []args){Scanner sc=new Scanner(System.in);label:System.out.println("Enter the number of cities");int noOfcities,nPerson;noOfcities=sc.nextInt();int under=0,obese=0,normal=0,over=0,c_under=0,c_obese=0,c_normal=0,c_over=0;double p_under,p_over,p_obese,p_normal;double max_normal=0.0,max_obese=0.0,min_under=100.0;String name,b_city="None",w_city="None",u_city="None",cat;int mass,height; while ( noOfcities<6){System.out.println("erro");System.out.println("Enter the number of cities"); noOfcities=sc.nextInt();}int i=0;while (i<noOfcities){i++;System.out.println("Enter the name of city");name=sc.next();System.out.println("Enter the number of persons");nPerson=sc.nextInt();while (nPerson<10){System.out.println("eror");System.out.println("Enter the number of…Java Program Fix this Rock, Paper and scissor program so I can upload it to Hypergrade and it can pass all the test cases. Here is the program, please fix thses program when I upload it to Hypergrade it does not pass the test cases and I can input any seeds as a command line. Also I do not need any thanks for playing or goodbye in the program: import java.util.Random; import java.util.Scanner; public class RockPaperScissors { public static void main(String[] args) { if (args.length != 1) { System.out.println("Please provide a seed as a command line argument."); return; } long seed = Long.parseLong(args[0]); Random random = new Random(seed); Scanner scanner = new Scanner(System.in); System.out.println("Enter 1 for rock, 2 for paper, and 3 for scissors."); do { int computerChoice = random.nextInt(3) + 1; // Fix computer choice range. int userChoice =…It's a fun program to make, I am just short on time.. import java.util.Scanner; class Employee { private final String firstName; private final String lastName; private final String socialSecurityNumber; public Employee(String f, String l, String ssn){ this.firstName = f; this.lastName = l; this.socialSecurityNumber = ssn; } public String getFirstName(){ return this.firstName; } public String getLastName(){ return this.lastName; } public String getSocialSecurityNumber(){ return this.socialSecurityNumber; } public String toString(){ return String.format("%s: %s %s%n%s: %s", "employee", getFirstName(), getLastName(), "social security number", getSocialSecurityNumber()); }} Create an HourlyEmployee class that inherits from Employee (I have the code copied below). Remember, HourlyEmployees get paid an hourly wage with time-and-a-half—1.5 times the hourly…
- Use the web to learn how to use the LocalDate Boolean methods isBefore(), isAfter(), and equals(). Use your knowledge to write a program that prompts a user for a month, day, and year, and then displays a message specifying whether the entered day is in the past, is today (the current date), or is in the future. import java.util.*; import java.time.*; public class PastPresentFuture2 { publicstaticvoidmain (Stringargs[]) { LocalDate today = LocalDate.now(); LocalDate enteredDate; int mo, da, yr; int todayMo, todayDa, todayYr; Scanner input =newScanner(System.in); System.out.print("Enter a month >> "); mo = input.nextInt(); System.out.print("Enter a day >> "); da = input.nextInt(); System.out.print("Enter a year (four digits) >> "); yr = input.nextInt(); // Write your code here } }Please comment each line of code explaining what it does. This is a tower of Hanoi java code Tower of Hanoi java code: import java.util.Scanner; public class TowerOfHanoi { public static void shift(int n, String startPole, String intermediatePole, String endPole) { if (n == 0) { return; } shift(n - 1, startPole, endPole, intermediatePole); System.out.println("Move \"" + n + "\" from " + startPole + " --> " + endPole); shift(n - 1, intermediatePole, startPole, endPole); } public static void main(String[] args) { System.out.print("Enter number of discs: "); Scanner scanner = new Scanner(System.in); int numberOfDiscs = scanner.nextInt(); shift(numberOfDiscs, "Pole1", "Pole2", "Pole3"); } }Convert the Java program below into an algorithm: package classProg; import java.util.Scanner; class Client { String name; int amount; Client(String name, int amount) { this.name = name; this.amount = amount; } public String toString() { return "\n Customer: \n" + name + " " + amount + " cents"; } } public class Main { Client client[]; static Scanner sc = new Scanner(System.in); int totalFifty, totalTen, totalFive; int currentIndex; Main(int no) { client = new Client[no]; currentIndex = 0; totalFifty = totalTen = totalFive = 0; } /** * Method to search a client name in the array of object * @param name - name to search * @return * If found returns the found index position * If not found returns -1 */ int findClient(String name) { for(int c = 0; c < currentIndex; c++) if(client[c].name.equalsIgnoreCase(name)) return c; return -1; } /** * Method to add a client to array of…