te the average kids per family. Note that the integers should be type cast to dou mport java.util.scanner;
Q: int Secret (int num1, int num2) if (numl > 0) for (int i = 1; i 0) for (int i = 0; i <= num2; i++)…
A: The working of Secret Function is to return the multiple of 2 or 3. If the value of num1>0,…
Q: A number (or a word) is called palindrome if it may be read in the same way from left to right as…
A: /* package codechef; // don't place package name! */ import java.util.*;import java.lang.*;import…
Q: Write an application that finds the smallest of several integers. Assume that the first value read…
A: Given: Write an application that finds the smallest of several integers. Assume that the first value…
Q: (Sort students on grades) Rewrite Listing 8.2, GradeExam.java, to display students in decreasing…
A: Approach To display students in decreasing order of the number of correct answers, we have used a…
Q: (java programming language) Given f(x) = x+ x2/2+ x3/3+…… xn/n. Using do-while, write a program to…
A: Code: import java.util.Scanner;public class Q3{ public static void main(String[] args) {…
Q: int comp_count (int x[], int N, int v)
A: According to the question we need to translate the given C code to Assembly Code: int comp_count…
Q: Trace the output for the following: %23include #include void main () { char charots = 'A'; for…
A: In the above code, here you can see that for each outer loop value , inner loop runs 5 times. Once 5…
Q: #include int main(){ int i=150.j=170, "pi=&i, *pj=&j; "pi=j-5; j="pi-5; printf("%d %d %d…
A: The code which you have mentioned is #include <stdio.h> int main(){ int…
Q: #include int main() { for(int i=1;i<8;i++) if(i % 2 == 1) for (int j=1;j<=i;j++); printf("%d",i); }…
A: The output of the above code is: 1 333 55555 7777777
Q: # include main () {int i, j; int A[4][4]; for (i=0; i<=3; i++) for (j=0; j<=3; j++) {- for (i=0;…
A: Given: The statements to generate 4x4 A array
Q: Java please Write code that will take number from user and will print table of that number in…
A: Algorithm: Take a number, n, from user. For i =1 to 10 print nXi = n*i
Q: What is the value of i and j after the execution of the following code i = Math.ceil(-2.1); j=…
A: Correct Option is (a) i=-2 and j=3
Q: void fact(int num) { int k,f=1; for (k=1;k<=num; k++) f=f*k; cout<< f; int main() { int…
A: Given:
Q: Can you help me with the codes required for this assignment? the programming langauge is Java.…
A: Given: Can you help me with the codes required for this assignment? the programming langauge is…
Q: void copy (int& a, int& b, int& c) { a *= 2; b*= 2; c*= 2; int main () { int x = 2, y = 5, z = 7;…
A: Given: We have the c program given in which we have to find out the return values.
Q: ComputeChange.java,to fix the possible loss of accuracy when converting a float value to an int…
A: Program: //include the header file import java.util.Scanner; //definition of class public class…
Q: Q1- Write a Java program with a method called multiplication Table that print calculates the…
A: Code: import java.util.*;public class Main{ Scanner sc = new Scanner(System.in);//scanner class…
Q: Write an application that allows you to enter nine integers and displays the values, their mean, and…
A: Mean is also known as average. The mean of n integers is calculated by adding all the n integers and…
Q: Write an application that asks a user to enter three integers. Display them in ascending and…
A: Ask user to input three integers say x, y and z. Check the following conditions for printing them in…
Q: Exercise 6 scanf (“%s", str); int len = strlen(str); for(int i=0; i<len; i++){ printf(“str[%d] =…
A: here have to determent about space complexity and time complexity of given problem.
Q: What is output when this Java code runs? int [] numbers = {3, 5, 6, 2}; int sum = 0; for (int I :…
A: 1) Java code snippet in question does below activities It defines a integer array numbers with…
Q: Analyze the following code. int count - 0; while (count < 100) { // Point A…
A: THIS IS MULTIPLE QUESTION BASED PROBLEM. ONLY FIRST QUESTION IS SOLVED. KINDLY SEND THE REMAINING…
Q: int i=0, sum = 2; do { sum--; i++; }while (sum>-1); What is the value of i after it is executed ?
A: i starting from 0 increments by 1 in each iteration
Q: int main() int i = 3, * j, k; %3D j = &i; k = i; j- 10; cout << i * *j* i+ *j*k; return 0;
A: The output of the given question has been explained and has been given in the next step.
Q: ublic static int methodA(int n) { int result 0; for(int i = 0; i ®; k--){ result += k; } return…
A: Time complexity defines the running time of the given program. OR , it defines the worst case…
Q: n
A: include <stdio.h> #include <conio.h> #include <stdlib.h> int ch; int e; void…
Q: F→ for( D ; B ; E ) { S } D→T id | T id , D T→ int | long B → id R id R→ == |!=||>= E– id O| id 0,E…
A: Need to find FIRST and FOLLOW for given grammar : Here bold value are terminals and Italic words…
Q: How to code - Public string getNames() and display the names on the output using Java.
A: The java.lang.reflect getName() function. The Method class is useful for obtaining the names of…
Q: Write 3 ways in java to find the string length without using length method. I am asking without…
A: Required:- Write 3 ways in java to find the string length without using the length method. I am…
Q: Rewrite the below Java assignments in the correct version. char aChar = 5.5; i. if (salesAmount >10…
A: Please find the answer and a sample program below. Then the program contains the examples of all the…
Q: void MyFunc (int n). if(n return; MyFunc(n-1); System.out.printin(n); what is the objective of this…
A: Java is a programming language. It contains extensive libraries (package). It can be used to create…
Q: Add the correct data type for the following variables: myNum 9; myDoubleNum = 8.99; myLetter 'A';
A: Given: 5 variables are given with their variable name and value. Requirement: Write the correct data…
Q: #include int mystery (int n) { if (n<=0) return 1; else return ( 3 + mystery (n-1)); void main()…
A: The program computes the value of i if it is greater than 0. It adds 3 for every recursive call. The…
Q: Math.pow(2, 3) returns 8.0 9.0 8
A:
Q: WAP to take two numbers from user and then perform mutliplication operation on these number and…
A: Requirements :- WAP to take two numbers from user and then perform multiplication operation on these…
Q: Analyze the following code. int count = 0; while (count < 100){ // Point A…
A: While loop is an entry controlled loop. It allows a part of the code to be executed multiple times…
Q: al tHe values a to and returns the result to main addltTogether (int a, int b) { int total = 0; %3D…
A: Here have to determine about code for get total between 2 numbers.
Q: This is the question and needs to be written in java: Write an application that accepts three…
A: Step 1: The string is defined as a combination of characters. For example abc Program Approach:-…
Q: b) void func (int n) { for sh (int i = 0; i < n; i = i + 10) { for (int j = 0; j < i; ++j)…
A: b. Worst case running time: void func(int n) { for (int i = 0; i < n; i = i + 10) { for (int j =…
Q: Exercise 1 Write a Java method random that generates and returns a random number between 14 and 59…
A: Given:
Q: Which class is used to generate random number? i) java.lang.Object ii) java.util.randomNumber…
A: Given, We have to find class is used to generate random number in JAVA Choices:…
Q: Q2: Write a complete program to test java.util Methods for Arrays and Random Numbers explained in…
A: Write a complete program to test java.until methods for arrays and random numbers.
Q: 7) #include int fun(int n) 11 { 20 if(n==0) return 5; return n+fun(n-1); } main() { printf("%d\n",…
A: In this question, we need to explain the code. The function uses the concept of recursion.
Q: (Find future dates) Write a program that prompts the user to enter an integer for today’s day of the…
A: Since there are multiple questions in this post, as per our policy, I'll answer the first question.…
Q: In Java take input two char variables from user and find the difference between their ASCII value.…
A: Take input two char variables from user using Scanner class in JAVA. Then find the difference of…
Q: Exercise 1 Write a Java method random that generates and returns a random number between 14 and 59…
A: Find Your Code Below
Q: The following program have syntax errors. Correct them. On each successive line, assume that any…
A: //Syntax errors in given codepublic class Exercise25{static final char = STAR = '*' //two…
Q: You may use any of the libraries that we have considered in this course (either algs4.jar or…
A: import java.util.HashMap; import java.util.Map; import java.util.Set; public class Details {…
Q: #include int *get( ) int y = 10; int *x = malloc ( return y;
A:
Q: 1 int computeArithmeticProgression(int num) 0; 2 int sum = 3 for (int i = 1; i <= num; i++) {
A: Given:
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- 1- class Excep { 2- public static void main(String[] args){ 3 try{ int arr[]=(1,2}; 4 int x = arr[1]/arr[0]-1; 6 7 catch(ArithmeticException e) 8- { 9. System.out.printin("divide by e"); 10 } 11 catch(ArrayIndexOutofBoundsException e) 12- { 13 System.out.println("wrong indexing"); 14 15 finally 16- { 17 System.out.println("Runtime error"); 18 } 19 }} 20 Answer:StringFun.java import java.util.Scanner; // Needed for the Scanner class 2 3 /** Add a class comment and @tags 4 5 */ 6 7 public class StringFun { /** * @param args not used 8 9 10 11 12 public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Please enter your first name: "); 13 14 15 16 17 18 System.out.print("Please enter your last name: "); 19 20 21 //Output the welcome message with name 22 23 24 //Output the length of the name 25 26 27 //Output the username 28 29 30 //Output the initials 31 32 33 //Find and output the first name with switched characters 34 //All Done! } } 35 36 37Please edit this class Authenticator. Remove breaks. Also create user array of size 100 rather than 3 different arrays. Also edit so it can be more OOP import java.util.Scanner; public class AuthenticatorApp { public static void main(String[] args) throws Exception { Scanner input=new Scanner(System.in); Authenticator obj=new Authenticator("user.data"); String Username,Password; boolean done=false; int count=0; while(count<3) { System.out.print("Username? "); Username=input.next(); System.out.print("Password? "); Password=input.next(); obj.authenticate(Username,Password); count++; } System.out.print("Too many failed attempts... please try again later"); input.close(); } } ------------------------------------------------------------------------------------------------------------import java.io.File; import…
- Question 2. package sortsearchassigncodeex1; import java.util.Scanner; import java.io.*; // // public class Sortsearchassigncodeex1 { // public static void fillArray(Scanner inputFile, int[] arrIn){ int indx = 0; //Complete code { arrIn[indx] = inputFile.nextInt(); indx++; } }Code example 2-1import java.util.Scanner;public class InvoiceApp {public static void main(String[] args) {Scanner sc = new Scanner(System.in);String choice = “y”;While (choice.equals(“y”)) {System.out.print("Enter subtotal: ");double subtotal = sc.nextDouble();double salesTax = subtotal * .0875;double invoiceTotal = subtotal + salesTax;String message = “Subtotal = ” + subtotal + “\n”+ “ Sales tax = ” + salesTax + “\n”+ “Invoice total = ” + invoiceTotal + “\n\n”System.out.println(message);System.out.print(“Continue? Enter y or n: ”);Choice = sc.next();}}}38. (Refer to code example 2-1.) If the user enters “Y” when asked if he/she wants to continue, the application will a. repeat the while loop b. display a blank line, then repeat the while loop c. EndCode example 2-1import java.util.Scanner;public class InvoiceApp {public static void main(String[] args) {Scanner sc = new Scanner(System.in);String choice = “y”;While (choice.equals(“y”)) {System.out.print("Enter subtotal: ");double subtotal = sc.nextDouble();double salesTax = subtotal * .0875;double invoiceTotal = subtotal + salesTax;String message = “Subtotal = ” + subtotal + “\n”+ “ Sales tax = ” + salesTax + “\n”+ “Invoice total = ” + invoiceTotal + “\n\n”System.out.println(message);System.out.print(“Continue? Enter y or n: ”);Choice = sc.next();}}} (Refer to code example 2-1.) If the user enters 100 the first time the while loop is executed, what will the program display at the console? a. Subtotal: 100.0 Sales tax: 8.75 Invoice total: 108.75 b. Subtotal = 100.0 Sales tax = 8.75 Invoice total = 108.75 c. Subtotal = 100.0 Sales tax = 8.75Invoice total = 108.75 d. Subtotal = 100.0 Sales tax = 8.75Invoice total = 108.75
- Warmup Write a method called countSuit) that takes an array of Cards and a String suit as parameters and counts how many of the cards have the given suit. Complete the definition of the class Warmup and method definition countSuit shown below. public class Warmup { public static int countSuit(Card [] cards, String suit) { // fill in code here } } For example, if we ran the following code in the main method: Card[] cards = new Card[4]; cards [0] = new Card (4, "clubs"); cards [1] = new Card (12, "diamonds"); cards [2] = new Card (1, "hearts"); cards [3] new Card(10, "diamonds"); System.out.println(countSuit(cards, "diamonds")); the output printed would be 2.public class TwoColors 10 { public static void main(String[] args) { Scanner in = new Scanner(System.in); 11 12 13 14 System.out.print("Enter your first favorite color: "); 15 16 // Step 2: Read in the next line of input and assign • it to a String variable color1 17 // 18 19 // Step 3: Trim spaces from both end and convert the // // 20 input to all lowercase and assign it back 21 22 to the same variable 23 24 System.out.print("Enter your second favorite color: "); 25 26 // Step 4: Read in the next line of input and assign 27 // it to a String variable color2 28 29 30 // Step 5: Trim spaces from both end and convert the // // 31 input to all lowercase and assign it back 32 33 to the same variable 34 35 // Step 6: Display a message according to the following: // 36 first color 37 second color message light blue 38 red That's wonderful! light blue 39 red That's even better! That's also great! 40 otherwise 41 4212 public class CircleAndSphereWhileLoop 13 { public static final doublğ MAX_RADIUS 14 500.0; 15 public static void main(String[] args) 16 17 Scanner in = new Scanner(System.in); 18 19 // Step 2: Read a double value as radius using prompt 20 // "Enter the radius (between 0.0 and 500.0, exclusive): 21 22 23 // Step 3: While the input radius is not in the ragne (0.0, 500.0) 24 Display a message on one line (ssuming input value -1) "The input number -1.00 is out of range. Read a double value as radius using the same promt 25 // // 26 27 28 29 double circumference = 2 * Math.PI * radius; double area = Math.PI * radius * radius; double surfaceArea = 4 * Math.PI * Math.pow(radius, 2); double volume = (4 / 3.8) * Math.PI * Math.pow(radius, 3); 30 31 %3D 32 33 %3D 34 // Step 4: Display the radius, circle circumference, circle area, // 35 sphere surface area, and sphere volume on separate lines with 6 decimal digits 36 37 // // Sample output // The radius // The circle circumference:…
- DEUGGING PROBLEM // Prompts user for a size using Scanner // Creates a frame with the specified size // that is twice as tall as wide import javax.swing.*; import java.util.*; public class DebugFourteen1 extends JFrame { public DebugFourteen1(int size) { super("This is my frame"); setSize(size, size + 2); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { Scanner kb = new Scanner(System.in); int size; System.out.print("Enter width for frame >> "); size = kb.nextLine(); DebugFourteen1 frame = new DebugFourteen1(size); frame.setVisible(); } }-9 is negative. 1 import java.util.Scanner; 2 1 pa 3 public class NegativeOrPositive { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); String condStr; int userVal; 4 5 ll 6. pa 7 8 9 userVal scnr.nextInt(); 10 11 condStr = /* Your solution goes here */; 12 is " + condStr + "."); System.out.println(userVal + } 13 14 15 }JvExampleja 1 package com.beginnersbook 2 import java.util.Scamer; 3 public class JavaExomple 4 ( 16 17 18 19 ) public static void main(String args[]) ( } float p, r, t, sinterest; Scorner scon new Scanner(Systen, (e); System.out.print("Enter the Principal: "); pscan.nextFloat(); System.out.print("Enter the Rate of interest: "); scan.nextFloat(); System.out.print("Enter the Time period: "); tscan.nextFloat(); scon.close(); sinterest (1)/100; System.out.print("Simple Interest is: interest); Problems Declaration Console Progress Cover JavaExample Java Application Library/JavalavaVirtual Machines|ck-2. Enter the Principel: 2000 Enter the Rate of interest: Enter the Time period 3 Simple Interest is: 360.0 Jevado