Problem 1 - Methods Write a program that has a loop of three iterations. In every iteration, the program should prompt the user to enter three integers then invoke a method called hasOddEven that takes the three integers as parameters and returns true if there is at least one odd and at least one even among the three numbers and that returns false otherwise. Below are some sample calls and the returned value: Method Call Value Returned |hasOddEven(2, 4, 6) False hasOddEven(2, 3, 4) True hasOddEven(12, 4, 17) True hasOddEven(7, 19, 5) False
Q: PART 2 Problem #2: [25 pts] Print Multiples a) Write a method printMultiples that takes two integers…
A: import java.util.Scanner; public class Main{ public static void printMultiplies(int x, int y){…
Q: Problem Description: In this assignment, you will need to write a program that will allow the user…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Problem Description: In this assignment, you will need to write a program that will allow the user…
A: Algorithm: Start Display menu to user and ask to choose and validate the choice If user selects 1,…
Q: True or False: When passing multiple arguments to a method, the order in which the arguments are…
A: Given: True or False: When passing multiple arguments to a method, the order in which the arguments…
Q: T/F 4. Java methods can return more than one item if they are modified with the reserved word…
A: Here is the solution which is mentioned below:
Q: JAVA Problem description: You are to write a program called Seasons that prompts the user for a…
A: Coded using Java.
Q: 6.17 LAB: Max magnitude Write a method maxMagnitude() with two integer input parameters that…
A: Java is programming language that can be used for the creation of the applications for the different…
Q: Write a program that analyzes an object falling for 10 seconds. It should contain main and two…
A: 1 meter = 3.28 feet
Q: Write a Java program that calls a method from main and passes it two integer parameters called…
A: The answer to the following question:-
Q: Financial Application:• Write a program that computes future investment value at a given interest…
A: Program plan:Import necessary packages.Define a class named “Investment”.Define a method named…
Q: The following recursive method has been created. This method accepts two integer parameters called a…
A: Step 1 The answer is given in the below step
Q: (Math: pentagonal numbers) A pentagonal number is defined as n(3n-1)/2 for n= 1,2, ..., and so on.…
A: Program description: The java class, PentagonDriver.java is to display the 100 pentagon numbers for…
Q: Write a program that prompts for an integer (that a side length) and displays, using asterisks, a…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: 1. Write a program that analyzes an object falling for 10 seconds. It should contain main and two…
A: I give the code in Java along with output and code screenshot.
Q: C# Question Write a statement that declares a variable called even and assigns it to the value…
A: Given: C# Question Write a statement that declares a variable called even and assigns it to the…
Q: (Number of days in a year) Write a method that returns the number of days in a year using the…
A: public class Solution { public static boolean isLeayYear(int y) { // if leap year…
Q: 1.Using pseudocode, a method that will add two numbers, and return the sum to the calling function.…
A: The, code has given below:
Q: This is only for python, code the progam. This program should record products and see how much…
A: 1) Below is program to record products and see how much money is spent on each. Add missing method…
Q: GetContestantNumber - This method gets and returns a valid number of contestants and is called twice…
A: Below is the implemented code for the given problem statement
Q: Write a method, countEvens(), that has four integer parameters, and returns the count of parameters…
A: A number is said to be even if number leaves remainder 0 on dividing with 2 The remainder on…
Q: It is used to access the instance variables shadowed by the parameters. Select one: O a. accessor…
A: Question 1: The shadowed instance variable can be accessed using the this keyword. The this…
Q: Code in C# (OOP Concept) Do a program that does the following: Ask for a number from the user in…
A: Step 1:- The first program in the C# programming language and the second program in the C++…
Q: Homework - identical arrays for one-dimensional: Write a test program which prompts a user to enter…
A: - The question is to check if the two arrays are identical or not. - We are using c++ here.
Q: Java Your program will read in a credit card number and expiration date from the user and validate…
A: The program makes use of Scanner class defined inside java.util package. The syntax for it is:…
Q: 6.18 Lab: Flip a Coin Define a method named coinFlip that takes a Random object and returns "Heads"…
A: As Language is not defined doing it in Java Language:
Q: Using a single for loop, write code that prints by 5s from 0 to 100. Your code should also print…
A: the program can be done using for loop and inside for loop we have to use a if statement to check…
Q: Using a single for loop, write code that prints by 5s from 0 to 100. Your code should also print…
A: We will write Java Code to solve the given problem.
Q: 1. Write a program that analyzes an object falling for 10 seconds. It should contain main and two…
A: As the programming language is not mentioned we are using JAVAThe JAVA code is given below with code…
Q: A for construct is a loop that processes a list of items. As a consequence, it continues to run as…
A: A looping construct is referred to as a "for" construct. It may be used to process a list of items…
Q: Recursive Power Method Write a method called powCal that uses recursion to raise a number to a…
A: Start Ask the user to enter the input. Perform the operation. Print the output. Exit.
Q: Complete the convert() method that casts the parameter from a double to an integer and returns the…
A: Algorithm: Start Implement convert() method which takes a double number as argument and returns an…
Q: C#Write a method MyMethod which takes an int parameter named x. This method calculates the sum of…
A: Given: C#Write a method MyMethod which takes an int parameter named x. This method calculates the…
Q: Exercise 6.14 JHTP: (Variable-Length Argument List) Write an application that calculates the product…
A: Solution:: Exercise 6.14 Code Screenshot : Executable Code: public class…
Q: list the arguments for the above call list the return type of sum here ______________
A: 1 public static int sum(int x, int y){ 2 int z = x +y; 3 return z; 4 } 5 public…
Q: True or FalseA value-returning method must contain a return statement.
A: Value-returning method: The value-returning method performs the task and does not terminate. The…
Q: Financial Application:• Write a program that computes future investment value at a given interest…
A: Program plan:Import necessary packages.Define a class named “Main”.Define a method named…
Q: By default, the equals method does the same thing as the operator. =D%D True False
A: = use for assign value == use for condition
Q: Method: sumOdds(value: int): This method will sum all the odd values from 1 upto the value passed by…
A: A Python code for the given methods is as follows,File name: “main.py”import randomdef…
Q: Write a method checkCharacter() which has 2 parameters: A String, and a specified index (an int).…
A: Hello student. Greetings from my side. Hope you are doing great. I will try my best to answer your…
Q: X609: Magic Date A magic date is one when written in the following format, the month times the date…
A: def magicDate(d, m, y): if d < 1 or d > 31: return False if m < 1 or m >…
Q: Task 2: Login System Implement the function loginUser() that takes two String as input, one for user…
A: Actually, string is a sequence of characters.
Q: 8. Sum of Numbers Write a method that accepts an integer argument and returns the sum of all the…
A: Algorithm: Start Implement a method named addNumbers() which takes a number num as argument Inside…
Q: Green Carpet Company wants a program to compute carpet costs. The program prompts the user for two…
A: Green Carpet Company wants a program to compute carpet costs. The program prompts the user for…
Q: 2. (Random number chooser) Write a method that returns a random number between 1 and 54, excluding…
A: Introduction of the program: The Java program generates a random number between 1 and 54 using the…
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: Write a program that simulates the game “hangman”.
A: #include<bits/stdc++.h>#include <unistd.h>using namespace std;class Node {private:…
Q: Green Carpet Company wants a program to compute carpet costs. The program prompts the user for two…
A: Green Carpet Company wants a program to compute carpet costs. The program prompts the user for…
Q: *6.7 (Financial application: compute the future investment value) Write a method that computes…
A: Solution :: 6.7 ) The following is the modfied program. you did not call the function…
Q: Problem 3 This problem is another table creation program, similar to Problem 1. In this program, you…
A: Algorithm: 1. Declare Celcius, Fahrenheit. 2. Create a method to accept a temperature in fahrenheit…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- 15. Even/Odd CounterYou can use the following logic to determine whether a number is even or odd: if ((number % 2) == 0){ // The number is even.}else{ // The number is odd.}Write a program with a method named isEven that accepts an int argument. The method should return true if the argument is even, or false otherwise. The program’s main method should use a loop to generate 100 random integers. It should use the isEven method to determine whether each random number is even, or odd. When the loop is finished, the program should display the number of even numbers that were generated, and the number of odd numbers.You are responsible for adding the appropriate testing code to your main. a. The getValedictorian method returns the valedictorian of the class, that is the student with the highest grade point average. Implement this new method. b. The getHonorsPercent method returns the percentage of students in the class who are in the honors program. Use 3.75 as the cutoff GPA. Implement this method. Also print the list of students, by using the isHonor method, in the Honors program. c. An alternate implementation for the School class is being considered, in which the students are stored in an ArrayList instead of an array. Show how the declaration of the data field students would look in this alternate design. MAIN CLASS: import java.util.ArrayList; public class Main { public static void main(String[] args) { System.out.println("Unit07Project2 by Your Name"); System.out.println(); int size = 10; School onw = new School(size); /* Add the code…Code in C# (OOP Concept) Do a program that does the following: Ask for a number from the user in the main method o Pass thenumber to a method call it "Multiplication”. In the Method Multiplication, multiply the number by a number enteredby the user (mention that the number should be positive). Send the result back to the main and print it from the mainModify the previous program if the user enters a negative second number in the method Multiplication, do not acceptthe number and ask the user to reenter it again. . Add another method call it also Multiplication Ask for a float numberfrom the main and send it to the new Multiplication. This method should also ask for another positive number fromthe user and multiply it by the float number. Design and implement a function called "multiply" in C++ that accepttwo numbers and returns either the arithmetic multiplication or repetition of a given string a specific number of timesdepending on the data types of the argument values. The…
- Method: sumOdds(value: int): This method will sum all the odd values from 1 upto the value passed by parameter. This will display the sumas an integer value.Method: characterCount(phrase: str): This method will count the number of characters in the phrase that is passed by parameter. You cannot useany built in function ( ie len() ) and must use a looping activity. This should display the number of characters inthe phrase as an integerMethod: multiplicationPractice(): This method is to practice simple multiplication problems. The program should randomly generate twonumbers from 1-10 for the user to multiply. It should display the multiplication problem and allow the user toanswer the problem. It should display if the user got the answer correct or incorrect. The activity shouldcontinue until the user has gotten 3 different practice problems correct.Method: order(value1: int, value2: int, value3: int): This method is to order the 3 passed value from least to greatest. It should display…Java Your program will read in a credit card number and expiration date from the user and validate the data. The program will continue to ask for user input until a valid number and date are entered. The rules for what is valid are specified below. readYear() and readMonth(int) methods Complete the readYear() and readMonth(int) methods. These methods ask the user to input the expiration year and month of their credit card. Each method should contain a loop inside the method so the code repeats until a valid month or year is entered by the user. If the user enters an invalid year or month, print an error message and ask them to try again. The readMonth(int) method reads in the month as a number. A valid month is any number between 1 and 12 (inclusive). A valid year is 2022 or later. readCreditCardNumber() method Complete the readCreditCardNumber() method. This method asks the user to input their credit card number. This method should contain a loop so the code repeats until a valid…C#Write a method MyMethod which takes an int parameter named x. This method calculates the sum of integers from 1 to x and returns the sum. Use a for loop.
- T/F 4. Java methods can return more than one item if they are modified with the reserved word continue, as in public continue int foo() {...}Q6. 1.Using pseudocode, a method that will add two numbers, and return the sum to the calling function. Note that the method will receive two numbers as arguments.C++ continued you already gave me the help from the first part. now they have added another set of instructions. original code used. Explanation Here I have created the main method. Inside the main method, I have taken input from the user for height and width and stored them into different variables. Next, I have created a loop that runs till it reaches the height of the rectangle. Inside the loop, I have created another loop that runs till the width of the rectangle. In the inner loop, I have printed the asterisk symbol. After the inner loop, I have used endl to give break and move the pointer to the new line. arrow_forward Answer C++ code: #include<iostream>using namespace std; int main(){ int height, width; // user input cin >> height >> width; // outer loop for(int i = 0; i < height; i++) { // inner loop for(int j = 0; j < width; j++) { //printing the * symbol cout << "*"; }…
- Computer Science Write a Java program that calls a method from main and passes it two integer parameters called minValue and maxValue. The method should prompt the user to enter a number within the range of minValue and maxValue (inclusive), until the user provides a valid input. The method should return the value provided by the user, and the program should display what the user entered after the method is called.6.17 LAB: Max magnitude Write a method maxMagnitude() with two integer input parameters that returns the largest magnitude value. Use the method in a program that takes two integer inputs, and outputs the largest magnitude value. Ex: If the inputs are: 5 7 the method returns: 7 Ex: If the inputs are: -8 -2 the method returns: -8 Note: The method does not just return the largest value, which for -8 -2 would be -2. Though not necessary, you may use the absolute-value built-in math method. Your program must define and call a method:public static int maxMagnitude(int userVal1, int userVal2) tested with 5,7 -8,-2, 25,-50 import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner input = new…I already have the code for the assignment below, but the code has an error in the driver class. Please help me fix it. The assignment: Make a recursive method for factoring an integer n. First, find a factor f, then recursively factor n / f. This assignment needs a resource class and a driver class. The resource class and the driver class need to be in two separate files. The resource class will contain all of the methods and the driver class only needs to call the methods. The driver class needs to have only 5 lines of code The code of the resource class: import java.util.ArrayList;import java.util.List; public class U10E03R{ // Recursive function to // print factors of a number public static void factors(int n, int i) { // Checking if the number is less than N if (i <= n) { if (n % i == 0) { System.out.print(i + " "); } // Calling the function recursively // for the next number factors(n, i +…