Given the following series: P(n)= 1-1/2+1/3-1/4+1/5...+1/n Write a java program that prints out the following table. It calculates and prints the value of P(n) for all odd integers <=35. Sample Run run: P(n) 1.000000 0.833333 0.783333 0.759524 0.745635 0.736544 0.730134 0.725372 0.721695 0.718771 0.716390 0.714414 0.712747 0.711323 0.710091 0.709016 0.708069 0.707229 BUILD SUCCESSFUL (total time: 0 seconds) 3 5 7 6. 11 13 15 17 19 21 23 25 27 29 31 33 35
Q: Write a java program calls the following methods: printStars(): Takes an int (n) as…
A: PROGRAM: //Header file import java.util.*; //Defining class class Main { //Defining…
Q: Write a java program that allows the user to enter his name and his year of birth, the program…
A: Start Take the input of the age. Compute the age. Print the age with years, month, days Print the…
Q: 1. Write a java program that asks the user to input two integers intStart and intEnd then computes…
A: Please find the answer below :
Q: 2. Write a java program that asks the user to type a positive number n and prints the series using…
A: In this question we have to write a JAVA program in which we will take the input from the user for a…
Q: In Java code Write a program that takes in an integer in the range 11-100 as input. The output is a…
A: Below is the required Java program: - Approach: - Import the package to use the Scanner class.…
Q: Write a program that reads from the user two integers and displays whether they have the same number…
A: Given:
Q: Given f(x) = x+ x2/2+ x³/3+.... x^/n. Using do-while, write a program to compute f(x) for given x…
A: Create a class Q3 because file name must be Q3.java Create variable sum that will store the sum of…
Q: Write a java program calls the following methods: a. printStars(): Takes an int (n) as parameter and…
A: The objective of the Main.java program is to prompt the user to enter the value for n. Then call the…
Q: Given the following summation. 1(1)= + +.+ |(i)= - 1+v2 VZ+V3 +Vi+1 Write a java program that prints…
A: /* (summation) write a program to compute the following summation input = I = 625 output…
Q: Given the following series: P(n)= 1-1/2+1/3-1/4+1/5...+1/n Write a java program that prints out the…
A: Algorithm: 1. Print "n", " ", "P(n)". 2. Run loop from i = 1 to i <= 35: 2.1. Initialize sum =…
Q: FOR JAVA Write a program that asks user to enter two numbers. Then the program should print the…
A: import java.util.Scanner; class Main { public static void main(String[] args) { int i;…
Q: Using Java Let |p|2 denote the size of p in bits. Your task is to generate a safe prime q, where…
A: ANSWER: Here is the program to print Sophie Germain's number beneath n. The answer for this is…
Q: Write a program that keeps reading integers from the user until he enters a negative number. The…
A: import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc=new…
Q: Write a Java program that prompts the user to enter a positive integer value between 5 and 45 and…
A: The program reads a value from the user using the Scanner object. Then declare and initialize the…
Q: Write a program that asks the user to enter a month (1 for January, 2 for February, etc.) and then…
A: Program plan: This software asks the user to enter any number from 1 to12, with 1= January, 2=…
Q: Java: Write a program that prompts for a sequence of integer inputs and displays cumulative totals.…
A: Here, first you need to declare integer array. Then you can prompt user to enter how many elements…
Q: Write a program to compute the sum of the first N Fibonacci numbers, where N is an integer that is…
A: import java.util.Scanner;public class Main{ public static void main(String[] args) { //declaring…
Q: Starting 2019, you are going to recruit a new employee for a period of 10 years with a monthly…
A: Note: This code should be rewritten instead of copying to the compiler otherwise it will throw a…
Q: Given the following series: P(n)=-1+1/2-1/3+1/4-1/5...+1/n Write a java program that prints out the…
A: Given that: a function P(n) given like this - P(n) = -1 + 1/2 - 1/3 + ..... + 1/n Calculate P(n)…
Q: Print the sum and subtraction result in main method.
A: Source code: import java.util.Scanner;public class Main{public static void main(String…
Q: Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's…
A: Program: File name: “LabProgram.java” import java.util.Scanner; //Create a class public class…
Q: Write a program that uses a random number generator to generate a two digit positive integer and…
A: Programming instructions: Include necessary header files. Declare the required variables. declare…
Q: Write a java program that reads n of type integer and calculates and prints the value sum of squares…
A: /******************************************************************************…
Q: write a java program. it reads a series of numbers (as double), andprint out the product of these…
A: Java used to answer this question
Q: Write a program that asks user to enter two numbers. Then the program should print the even numbers…
A: The code is as follows:-
Q: Write a java code that finds the following of a given number without using Math.log() or Math.pow():…
A: The answer for the above mentioned question is given in the following steps for your reference.
Q: Write a program that reads an integer value and prints the sum of all even integers between 2 and…
A: Solution: Given, Write a program that reads an integer value and prints the sum of all even…
Q: Write a program that simulates throwing a dices n times
A: Below is solution python program with detail explanation using python comments. import random def…
Q: Using the java language create a program that takes a value as in input from the keyboard and…
A: Given :- Using the java language create a program that takes a value as in input from the keyboard…
Q: Given the following summation. 1. I(i) = 1+v2 ... VZ+V3 Write a java program that prints the value…
A: import java.lang.Math; public class SumSquireRoot { public static void main(String[] args) {…
Q: Given f(x) = x+ x2/2+ x3/3+. x"/n. Using do-while, write a program to compute f(x) for given x and…
A: I have provided the java program asked in the question. We can not upload a file in this. Kindly,…
Q: Write a program that uses a random number generator to generate a two digit positive integer and…
A: Programming instructions: Include necessary header files. Declare the required variables. declare…
Q: Write a Java program that sums a series of 10 numbers without duplicates. These numbers are supposed…
A: Given: Write a Java program that sums a series of 10 numbers without duplicates. These numbers are…
Q: Write a JAVA program using loop that asks the user to input seven integer numbers representing-..…
A: I have given an answer in step 2.
Q: Write a program using integers userNum and divNum as input, and output userNum divided by divNum…
A: JAVA Program: import java.util.Scanner; class Number { public static void main(String[] args) {…
Q: write in JAVA LANGUAGE Create a program that will compute PRELIM, MID-TERM, PRE-FINAL, FINALS GRADES…
A: Task : Collect the 3 quiz marks in Prelim Midterm Pre-Finals Finals Output the list of grades…
Q: • Write a program that asks the user for a number n and prints the sum of the numbers 1 ton. By used…
A: <!DOCTYPE html><html><body><script>//asking user to enter valuevar…
Q: The value of S is computed from the formula: S = 1/1 + 1/2 + 1/3 + 1/4 + 1/5 + … + 1/N Using Do…
A: Introduction of Program: In this java, program sum is calculated using the below formula and the…
Q: In JAVA language, write a program to input an integer p from the user and then print the count of…
A: In JAVA language, write a program to input an integer p from the user and then print the count of…
Q: Write a program using JAVA that asks the user for a number n and print the sum of the multipl
A: required: Write a program using JAVA that asks the user for a number n and prints the sum of the…
Q: Write a java program that reads n of type integer and calculates and prints the value sum of squares…
A: Java Code
Q: Write a program that keeps reading integers from the user until he enters a negative number. The…
A: According to the Question below the Solution: Output:
Q: Write a program that reads from the user two double values x and y and two integer values a and b.…
A: Here I have taken input from the user and then stored it in different variables. Next, I have…
Q: Using Java, This program should print out first N powers of 2 starting from 2^1, until 2^N. The…
A: Please find the answer below
Q: What is the output for the following java code? int sum for (int x=15; x<=50; x+=10) sum+=x;…
A: ANSWER:-
Q: Write a Java program to find the sum of odd numbers till n. You have to take n from the user.
A: Required: Write a Java program to find the sum of odd numbers till n. You have to take n from the…
Q: Given the following series: P(n)=-1+1/2-1/3+1/4-1/5...+1/n Write a java program that prints out the…
A: import java.util.Scanner; public class sumseries { public static void main(String[] args) {…
Q: Write a java code that finds the following of a given number without using Math.log() or Math.pow():…
A: Here is the code to calculate the log of a number n:
Q: Write a Java program that prompts the user to enter two positive integers and find their greatest…
A: Given: Greatest common Divisor
Q: Write a java Program that display the numbers with duplicates from a set of numbers entered by the…
A: import java.util.*;public class Main{ public static void main(String[] args) { Scanner…
Step by step
Solved in 2 steps with 1 images
- Write a Java program that reads two positive integers num1 and num2 (assume num1 < num2). Then, the program will display all perfect numbers between num1 and num2. A positive integer is called a perfect number if it is equäl to the sum of all of its positive divisors, excluding itself. For example, 6 is the first perfect number because 6 = 3 + 2 + 1. The next is 28 = 14 + 7 + 4 + 2 + 1. Hint: use modulus (%) to find the divisor of a number. Sample Input/Output Enter two numbers: 6 1001 6 is a perfect number 28 is a perfect number 496 is a perfect number Note: Your answer should follow the given sample input / output.in java Use scnr.nextInt() to read integers from input into inputData until 1000 is read. For each remaining integer read before 1000, if the integer is non-positive, output the integer followed by a newline and add the integer to sumOfSelected. Ex: If the input is -23 13 -5 -4 -17 1000, then the output is: -23 -5 -4 -17 The sum of all non-positive values is -49 Note: The sentinel value is 1000.Write an application that reads an integer value from the user and prints the sum ofall even integers between 2 and the input value, inclusive. Print an error message ifthe input value is less than 2. Use Java. Sample Run Examples: Example 1:the user enters 14Output: Sum: 56Example 2:the user enters 1Output: Error number must be greater than 1
- IN JAVA. Write a program that takes in an integer in the range 20-98 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical. Ex: If the input is: 93 the output is: 93 92 91 90 89 88 Ex: If the input is: 77 the output is: 77 Ex: If the input is: 15 or any number not between 20 and 98 (inclusive), the output is: Input must be 20-98Write code which prints every number from 10 to 1 a number of times equal to the number itself (e.g. ten 10’s, nine 9's...). Every individual number printed should be separated by a space, and there should be a new line each time the number changes. You should use nested loops to produce your output (it will result in far less code). in JAVA Partial sample run: 10 10 10 10 10 10 10 10 10 10 9 9 9 9 9 9 9 9 9 8 8 8 8 8 8 8 8 ........Write a program CheckDigit.java that takes a 12 or 13-digit long as a command-line argument and displays the digit computed as follows: Take for an example the number 048231312622 Sum every other digit of the code, starting from the right. In the example, that is 2 + 6 + 1 + 1 + 2 + 4 = 16. Discard the tens digit and keep the ones digit, 6. Start with the second to last digit and do the same thing. Sum the digits, discard the tens digit and keep the ones digit. In this example this is 2 + 2 + 3 + 3 + 8 + 0=18. Discarding the 10 leaves 8. Multiply this number by 3 and again discard the tens digit. 8×3 = 24, leaving 4. Add the numbers from steps 1 and 2. Again drop the tens digit. 6 + 4 = 10, leaving the digit 0 (zero). Hint 1: the maximum value that can be stored in an integer variable is 2147483647 which is only 10 digits long. To read a 12 or 13-digit integer from command line argument you will need to store it in a long variable. Use: long number =…
- Write a Java program PrintTriangle, to print a triangle. Ask the user, how many rows you want in your triangle? Keep on asking the user to enter the number greater than 1 until he/she enters positive number greater than 1. Print them in ascending order, first row should have one plus sign, second row should have 2.....fifth row should have 5.(PLEASE USE BASIC JAVA NOT COMPLEX I AM A BEGINNER THANKS) Canadian phone number has the following format: +1 (604) 295- 8959 Area Code= Three digits starting with 2-9Prefix= Three digits starting with 2-9Subscriber= Any four digits 0-9Write a java program, using loops, that asks the user to enter a phone number then if correct print theArea Code, Prefix, and Subscriber numbers. If not correct, print what is wrong. Sample run:Enter a number or -99 to quit: +1 (604) 277-9999The number is correct with area code: 604, prefix 277, and subscriber 9999Enter a number or -99 to quit: 1 (104) 277-0123Country code doesn’t start with + and area code doesn’t start with a 2-9 number.Write a java program call CountVowelsDigits which prompts the user for a string, counts the number of vowels(a,e,i,o,u,A,E,I,O,U) and digits(0-9) contain in the string, and prints the counts and percentages rounded to 2 decimal places. Enter a String : testing12345 Number of vowels is: 2 (16.67%) Number of digits is : 5 (41.67%)
- Write a java program that uses isPrime() to find a factor of the number n, if the factors are greater than 2, return that the number is not prime. Otherwise to return that the number is prime. The method is called in the program that prompts the user to enter a number and displays to the user whether the entered number is prime or not. public static void isPrime(int n) { //This is a segment of a program that you need to write and run } ******WRITE THIS IS JAVA PLEASEWrite a simple calculator which supports add subtract multiply and divide. Prompt the user for two numbers and an operation. Use number 1-4 for menu options. If divide is selected and the second number is zero, output an error message. If an invalid menu option is selected, output an error message. If all is well, perform the operation and output the result to one decimal. Please write in Java that results like test case examples. ThanksWrite a complete Java program that allows users to enter two integer numbers as follows: pleaes Enter the first number: 2 please Enter the Second number: 2 Upon providing the two integer numbers, the users should be given a list of operations to select from, as follows: please choose the operation you want to do with these numbers by Enter a,b or c: a- adding b- multiplying c- average Based on the users’ selection, a method should be called to perform the selected operation and return the result. After that the main method should print the result. The output of the program should be as follows in the picture: