Write a program that computes the power of an integer a* where the base is a and the exponent is x, recursively. You should write your code in a single file named “Problem2.java" which contains a main method that reads in integer base a from users and exponent x and calls method power to perform the computation recursively.
Q: JAVA: Write a program that reads an integer and prints how many digits the number has, by checking…
A: Given: Write a program that reads an integer and prints how many digits the number has, by checking…
Q: Write a java program ( One class with a main method ) to do the following : 1. Prompt the user to…
A: Actually, java is a object oriented programming language. It is a platform independent. It is a high…
Q: What is the result of the following code segment in Java? int x-38; System.out.println(++x); Оа. 38…
A: EXPLANATION: In the given code segment, the variable is declared and initialized of type integer…
Q: Add a Method to Accept names and marks of n students from user, enter the value of n from User…
A: EXPLANATION Create a simple class student which will have two fields name and marks. Now call…
Q: How to do it in the JAVA language? Write a program that has the following "static" return value…
A: We have to write a Java program Which has static" return value methods. The parameters have…
Q: Write a Java program to do the following task: Create an integer array of size 15. Input the values…
A: PROGRAM CODE: import java.util.*; // import utility package for javapublic class Main{…
Q: I need to create a method in java called runSecantMethod(double p0, double p1, double tolerance, int…
A: Coded using Java.
Q: a. Write a Java method called longestWord that takes one argument which is a 1D arr of String of…
A: The program is implemented in Java with structured approach. We have an array of strings arr1 which…
Q: Make a recursive method for factoring an integer n. First, find a factor f, then recursively factor…
A: Make a recursive method for factoring an integer n. First, find a factor f, then recursively factor…
Q: Consider the following Java code fragment. The numbers on the left are line numbers for reference…
A: Java Code: class Code{ public static void main (String[] args) throws java.lang.Exception { // your…
Q: Write a Java program to input a single dimensional integer array of size 10. Pass the array to a…
A: Sample Response: //Java program, tested on drJavaimport java.util.Scanner;public class…
Q: A company wants to secure users' passwords that consists of four digits only by encrytping them.…
A: The programming methodology for the program is given by: Including header files Function prototype…
Q: Write a Java program that does the following: 1. In the main() method complete the following: 1.…
A: import java.util.*;public class Main { static String leaveHospital(ArrayList < Double > []…
Q: Write a method that takes an integer array, prints the elements that are divisible by 3 and returns…
A: Here, According to the instruction we will take an array and print the elements which are divisible…
Q: Write a Java method sumNoFives() that will receive as input two ints A and B and will return the sum…
A: - We need to have code for inclusive sum except the multiples of 5. We need to use java here.
Q: Write a complete Java program with comments in main and in each method. Create your own names for…
A: import java.lang.*;import java.io.*; class main{ static ArrayList<String> exam = new…
Q: •Write a class, ComputeGCD, which will do the following: –The main method will: •Prompt the user for…
A: Program code: //import the required packages import java.util.Scanner; //define the class GCD…
Q: Write in Java: Given main(), complete the Car class (in file Car.java) with methods to set and get…
A: public class Car { private int modelYear; // TODO: Declare purchasePrice field (int) private int…
Q: Write a Java program that performs the following steps: Prompt the user to input two positive…
A: Note: - As per the guidelines we can only answer one question at a time. Please re-submit the other…
Q: Write a static method histogram() that takes an array a[ ] of int values and an integer M as…
A: The static method histogram() is shown below. //method definition public static int…
Q: Consider the following Java method. Which term best describes what this method computes? static int…
A: Incorrect options: a. average To find the average, one needs to find the sum of all array elements…
Q: Write a complete Java program that provides two methods named randomlnteger(arr) and…
A: Here I have first of all defined 2 user-defined methods, one to generate the random numbers and the…
Q: Write a Java program that has a class named TEST2 which contain the method named SUM1 to find the…
A: Here I have created a function named SUM1(). This function iterates over the list of numbers and…
Q: 3. A program that prints the power table for integers from 1 to 5. The table must include the…
A: public class Main{ public static void main(String[] args) { System.out.print("\t\t\t\t\tPower…
Q: Write a program in java . Create a class names “A” with a method to print “ method of class A”.
A: public class A { //creating a class name A public void…
Q: 1. Write a Java method "printNTimes" to print a given string for a given times. Your method should…
A: NOTE: As per our guidelines we are supposed to answer only one question so please post the second…
Q: Write a Java program that will compute the greatest common divisor using recursive method. The…
A: The following java program will help in calculating GCD: //for using scanner object import…
Q: Write a Java method that takes a two-dimensional ragged array as input and uses that array to print…
A: The Answer is
Q: Write a java program to help kids to learn the multiplication table. a) Define a method called…
A: program: import java.util.*;public class Main{ public static void main(String[] args) { int n;…
Q: int a = 5; Student b = new Student (); How much total bytes will be occupied by variable a and b?
A: The answer is:
Q: Write a java program to help kids to learn the multiplication table. a) Define a method called…
A: The program is written in Java. Check the program screenshot for the correct indentation. Please…
Q: Write a java program which asks the user to enter name and age and calls the following methods: a.…
A: Actually, the answer has given below:
Q: Write a Java program that performs the following steps: Prompt the user to input two positive…
A: The code is written below- #include <iostream> // header files using namespace std; int…
Q: Write a program called Guests.java that prompts a user to enter how many guests he will host. Next,…
A: Step-1: StartStep-2: Print message "Enter the number of Guests on the List:"Step-3: Declare an…
Q: Write a java method that takes four integers as arguments (int a, int b, int c, int d), that prints…
A: The above question is solved in step 2 :-
Q: Write a Java application that calculates the sum of a series of integers that are passed to method…
A: As given, I need to write a java program with sum() method which takes variable-length arguments and…
Q: Write a program that will help an elementary school student learn multiplication. Use a Random…
A: #include<iostream> #include <stdlib.h> #include<string> using namespace std;…
Q: Java - public static void test_a(int n) {…
A: Java Sun Microsystems initially introduced Java, a programming language and computing platform, in…
Q: Write a java method that receives two integers called n1 and n2 and then returns the number of…
A: Required: Write a java method that receives two integers called n1 and n2 and then returns the…
Q: Write a static recursive method in Java called mRecursion that displays all of the permutations of…
A: import java.util.Scanner;public class Main { //Get input from in to call recursive method //to…
Q: You have a card on which the letter J is written on one side and K on the other. You want to see all…
A: Java Code Card.java public class Card{ public static String str= ""; public static void…
Q: Write a java program (One class with a main method) to do the following: 1. Prompt the user to enter…
A: Algorithm: 1.importing util package for scanner class 2.create object for scanner class to get…
Q: Write a complete Java program with comments in main and in each method. Create your own names for…
A: import java.util.*;import java.lang.*;import java.io.*; class main{ static ArrayList<String>…
Q: Write in Java. Write a method with the following header to format the integer with the specified…
A: import java.util.*;import java.lang.*;import java.io.*; class HW2_P1{ public static String…
Q: in java Write a RainFall class that stores the total rainfall for each of 12 months into an array…
A: Here is the Java Program: import java.io.*;import java.util.*;public class Rainfall { public static…
Q: Write a complete Java program that provides two methods named randomInteger(arr) ar lastIndexof(arr,…
A: It is defined as programs can be asked from control statements, array, string, oops etc. Java basic…
Q: Write a Java method that receives a two-dimensional array of primitive ints ( int [] [] ). The array…
A: public static double averageArray(int arr[][]){ double sum = 0, numberOfElements = 0, average;…
Q: Write a Java method that takes an array and a variable of type int and returns an int value. The…
A: Find Your Code Below
Q: Write a method hat takes a list of Book and a String as parameters. This method supposed to search a…
A: Book is a class and should has basic attributes to store the name and info which are used to compare…
** in java language **
Step by step
Solved in 2 steps with 3 images
- Chapter 4. PC #14. Line Numbers (page 265) Write a Java program that asks the user for the name of a file. The program should display the contents of the file with each line preceded with a line number followed by a colon. The line numbering should start at 1. I should be able to run the program in my compiler and type input1.txt and it should print out the output. Here are the test cases that it should pass Test Case 1 Please enter the file name or type QUIT to exit:\nquitENTER Test Case 2 Please enter the file name or type QUIT to exit:\nbadfilename.txtENTERFile: badfilename.txt does not exist.\nPlease enter the file name again or type QUIT to exit:\nquitENTER Test Case 3 Please enter the file name or type QUIT to exit:\ninput1.txtENTER1: a\n2: b\n3: c\n4: d\nPart 1: Write a C/C++ language program that creates an array of 10,000 random unsigned integers in the range 1 to 1,000,000. These integers are then stored in a text file called numbers.txt Part 2: Write a C/C++ language program that reads the file numbers.txt and checks each number for being a prime number. Only the prime numbers from these are then written to a text file prime.txt. Part 3: Modify the program of part 2 so that it takes an input argument num_jobs with a value between 1 and 8. E.g. if num_jobs is 3, it splits into 3 parallel processes using fork() function, and each process then calculates prime numbers from a subset of the input data. Together these 3 jobs find prime numbers from all the 10,000 input integers. The overall parent process then combines the results from its children into a single file prime.txt Part 4: Calculate the times taken by running the program of part 3, and make a table where the time taken for calculation is given for each value of num_jobs from…Hello,I got this error message for the following C program: the contents of words.txt file are: Segmentation fault (core dumped) QUESTION: Write a few statements that open a file called "words" and writes the last word in the file to a file called "lastword". PROGRAM: #include <stdio.h> int main(void) { char ch,file_name[25]; FILE *fp,*fn; char name[20]={"lastword"}; int i; fp=fopen("words.txt","a"); fprintf(fp,"%s\n",name); fclose(fp); fopen("words.txt","r"); printf("the contents of words.txt file are:\n"); while((ch=getc(fp)!=EOF)) { fprintf("%c",ch); } fclose(fp); fp=fopen("f://words.txt","r"); fn=fopen("f://lastword.txt","w"); while((fgets(file_name,25,fp))!=NULL) { printf("%s\n",file_name); if(strcmp(name,file_name)==0) { fprintf(fn,"%s/n",file_name); } } fclose(fp); fclose(fn); }
- JAVA PPROGRAM ASAP Please Modify this program ASAP BECAUSE IT IS MY MIDTERM so it passes all the test cases. It does not pass the test cases when I upload it to Hypergrade. Because RIGHT NOW IT PASSES 1 OUT OF 7 TEST CASES. And dont forget to take out and change the following in the program: System.out.println("Program terminated."); because the test case does not need it And change this in the program: Please enter the file name or type QUIT to exit:\n so it reperats once for every test case because it repeats twice in every case as shown in the screenshot. I only need it once. I have provided the failed the test cases and the inputs as a screenshot. The program must pass the test case when uploaded to Hypergrade. import java.io.*;import java.util.ArrayList;import java.util.Scanner;public class SymmetricalNameMatcher { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String fileName; do { // Prompt the user…USING FILE POINTERS IN C PLEASE . Write a program that prints a table of all the Roman numeral equivalents of the decimal numbers in the range 1 to 50. Knowing that the roman numbers (from 1 to 10) are as follows: I, II, III, IV, V, VI, VII, VIII, IX, X. Note that 50 is represented by L. COMMENT ALL OF YOUR STEPSIn java create a function that writes student name surname and id to a text file and call the function (registerstd) in main function. the function must accept the arguments name , surname and ID
- def tpr(tp, fn): # TODO return def TEST_tpr(): tpr_score = tpr(tp=100, fn=1) todo_check([ (np.isclose(tpr_score,0.99009, rtol=.01),"tpr_score is incorrect") ]) TEST_tpr() garbage_collect(['TEST_tpr'])I need memory drawing of this program #include<iostream>using namespace std;class student{string name;int id;float gpa;public:student* next;//next = &student;void getdata(){cout<<"Enter the name of the student "<<endl;cin>>name;cout<<"Enter the id "<<endl;cin>>id;cout<<"Enter gpa "<<endl;cin>>gpa;}void showdata(){cout<<"Student name : "<<name<<" Id: "<<id<<" gpa "<<gpa<<endl;}};// ....int main(){student* s[10];for (int i = 0; i < 8; i++){cout << "enter student data\n";s[i] = new student(); //create objects[i]->getdata();s[i]->next = s[i + 1];}for (int i = 0; i < 8; i++){s[i]->showdata();}}This file has syntax and/or logical errors. Determine the problem and fix the program. // Employee's salary should not be negative // Include stack trace when exception occurs using System; using static System.Console; class FDebugEleven03 { static void Main() { Employee emp = new Employee(); try { emp.IdNum = 234; emp.Salary = -12; } catch (NegativeSalaryException e) { WriteLine(e.Message); WriteLine(e.StackTrace); } } } public class NegativeSalaryException : { private static string msg = "Employee salary is negative."; public NegativeSalaryException() : base(msg) { } } public class Employee { private int idNum; private double salary; public int IdNum { get return idNum; set idNum = value; } public double Salary { get {…
- a) Write a c++ program which contains a function isPalindrome, the function checks a stringusing pointers whether it is a palindrome or not and based on the decision return Ture orFalse. A string/word that reads the same backwards as forward is known as palindrome.E-g MADAM , POP , BOB etcb) Write a program that takes a char array (char *) that take your name as input, a charpointer point it and convert lower to upper and vice versa.Do the following program in Java Eclipse:A veterinarian services many pets and their owners. As new pets are added to the population of pets being serviced, their information is entered into a flat text file. Each month, the vet requests a listing of all pets sorted by their outstanding bill balance. You have to write a program to produce a report of animals and their owners sorted by theiroutstanding bill balances from the data in the flat text file. Below is a description of the information on the text file:• The first entry is the number of animals on the file (numeric)• The fields below repeat for each animal:o Owner name (String)o Birth year (numeric)o Bill balance (numeric)o Species (String)o Special feature (numeric or String)The animals serviced by the veterinarian are of four types: mammals, fish, birds, and reptiles.For a mammal, the special feature field on the flat file is the number of legs of the animal (numeric).For a fish, the special feature field is the type, bony,…1-Write a JAVA program that reads an array from input file and invokes twodifferent methods Sort and Max ,that sorts the elements of the array and findsthe Max element and writes out the resulted array in to output file . Usetwo interfaces for methods and throw Exception Handling for Out Of Boundindex for the array