import java.lang.*; import java.util.*; public class MoneyInBank { public static void main(String[] args) { Scanner keyboard = new Scanner (System. in); float annualRate = 8;
Q: What will happen if the following fragment of code is executed? If there will be an error, explain…
A: The given sample is written in Java program where below are the classes relationships: Class A: A…
Q: How about we call a positive integer n customary if in the decimal documentation every one of its…
A: Here have to determine about call a positive integer problem statement.
Q: Complete the following method, prefix(String s1, String s2), which returns true if s7 is a prefix of…
A: Here is the java code of above problem. See below step for code and output.
Q: This is a debugging problem that I am completely stuck on. This is the question - The files provided…
A: Introduction of Program: In this program, The user will press 1 for Burger, 2 for Hotdog, 3 for…
Q: Write a program that checks matching words - First asks the user to enter 2 String variables word1…
A: Note: The program has been provided in Java. Java has two methods to compare strings.…
Q: This is a debugging question I am stuggling with - The files provided in the code editor to the…
A: public class DebugSeven2{ public static void main(String[] args){ String str; int x;…
Q: iii. Consider the expression T|F^ T. In how many ways can the expression be parenthesized so that…
A: Question iii. Consider the expression T | F ∧ T. In how many ways can the expression be…
Q: What is inlining, and when might it be beneficial? Why, in the following code, is the compiler…
A: Note: We are authorized to answer one question at a time, since you have not mentioned which…
Q: Complete the following method, prefix (String s1, String s2), which returns true if s1 is a prefix…
A: Below I have provided Java Programming. Also, I have attached the screenshot of the code and output…
Q: Is it You, Cody? Can you identify if Cody's name is spelled right? If so, then make a program that…
A: Please refer below for your reference: Language used is C++: #include <iostream>using…
Q: What is printed by the following? Show the output EXACTLYas it would appear.SHOW YOUR WORK
A: Program execution: The variable red and blue is initialized:red[31]="one jacket";blue[31]="two…
Q: What will be printed out after the execution of the following program?
A: given program and saying what will be the output .
Q: Convert the following while-loop into an equivalent for-loop as closely as possible using the code…
A: According to the information given:- We have to fill in the blank in the mentioned code:-
Q: What is the output for the following program? #include void main( ) Answer: { int sum, f= 10, d =…
A: #include <stdio.h>int main(){ int sum,f=10,d=20,i = 5, j=3; sum = f+i; if(sum…
Q: - What is the time complexity of the following codes? А. void fun(int n, int x) { for (int i = 1; i…
A: Here in this question we have given two code segment and we have asked to find the time complexity…
Q: Use following series to do the given task; 1 35 7 9 11 13 15 17 19 21 23 25 27 29 31 ... Given the…
A: - We need to code for the sum problem of last three odds. - We are using python here.
Q: 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42…
A: Rewrite the previous program by using while nested loop ? And the result must be as the following…
Q: Write a program that will compute and display the sum of all whole numbers between 1 and 100…
A: C code :- #include<stdio.h> int main() { int i=1,sum=0; do{ sum+=i;…
Q: Convert the following for-loop into an equivalent while-loop as closely as possible using the code…
A: The code is given below.
Q: Rewrite the previous program by using for nested loop ? And the result must be as the following 1…
A: Given data is shown below: Rewrite the previous program by using for nested loop ? And the result…
Q: write a Java program that will prompt for and read one word of length greater than 3 entered by the…
A: In this program, we will use java.lang.String and java.lang.StringBuilder for our purpose
Q: Trace the following code and write what it does. void Finals(X, Y, m, n) int i1, ju1, k1; while (i…
A: We are given the following code and we need to trace what it does. void Finals(X, Y, m, n){ int…
Q: Investigate the output 12 16 20 24 15 20 25 30 18 24 30 36 And find the values for variables start,…
A: start=4 end=6 first=3 last=7
Q: Write a code to enter values, print, and search using binary search in a single filter and of the…
A: public class Main{ public static void binarySearch(int A[], int f, int l, int key){ int m = (f +…
Q: What is the output of the following code ? try: b=[5,7,4,8,9] sum=m+b[@]+b[1]+b[4] print(sum/b[4])…
A: Lets see the solution.
Q: Task-04: Write a program that takes a sentence from user and print that sentence in reverse order.…
A: 1- As per the assignment requirements, create a string variable as a sentence and initialize the…
Q: Here is another mathematical problem, where the trick is as much to discover the algorithm as it is…
A: Start Take the input string. Read the string Find the all permutations. Print the permutations Stop
Q: CHALLENGE ACTIVITY 8.3.3: Hourly temperature reporting. Write a loop to print all elements in…
A: Step 1 The code is given in the below step with an output screenshot.
Q: Write a program which ends when a user types a user- defined letter. 1. Get an english letter as a…
A: Algorithm: do{ // loop body }while(condition);
Q: Trace the evaluation of the following expressions, and give their resulting values. Make sure to…
A: Since there are multiple sub parts of the question we will solve the first two for you
Q: Why, in the following code, is the compiler unable to move the call to strlen out of the loop?…
A: The compiler is unable to move the call to strlen out of the loop as the result does not change from…
Q: Answer Input The first line is an integer N that represent the test case. Followed by N lines, where…
A: We have to create the KFry class which will contain the fields given in it. The input is taken in…
Q: tified statements about integers. In this problem, the domain is the set of all integers. Which…
A: As per policy, we will be doing only 3 sub-parts: a.) ∃xx+x=1 This statement is FALSE as 1 is the…
Q: Binclude using namespace std; gint main() float average; const int FIVE 5; int doublea 243; double…
A: Correction: The above program contains some errors: Variable 'average' is defined for two times. In…
Q: What is the output of the following program? #include int main() char s[ ]=" map"; int i;…
A: Here s is a character array storing value as follows m a p \0 \0 mean null terminator ie…
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: 4) Trace the evaluation of the expressions and give the resulting values. (Make sure to give a value…
A: I have solved 4.d in step 2 for you. Kindly check step 2 for the answer. Do upvote if you find this…
Q: 21.4 LAB: Parsing dates Write a program to read dates from input, one date per line. Each date's…
A: Python program to solve the given problem is below.
Q: Please find the remark "for question 3" in the given incomplete program. What should replace the…
A: We are given an incomplete java code having blank spaces as several places. As per he question, we…
Q: What does the code below do if I answer "s"? Comment on the code to show what the different parts…
A: Python allows to use of randint() function to generate a random number, To generate a random number,…
Q: Trace the following code and write what it does. void Finals(X, Y, m, n) { int i=1, j=1, k=1; while…
A: void Finals( int X[], int Y[], int m, int n){ int i=1, j=1,k=1; //checking the value of i and…
Q: 3. What is the screen output of the following program? Write your answer in the box provided.…
A: As your your question is about writing output of your code. so let's see output of the code on the…
Q: Write a line of Java to add 1000 to the int variable count. Use a shortcut operator. Edit
A: code is given below:
Q: Given the following code, what initial values for num will cause an error during execution? int…
A: Given:
Q: What is the screen output of the following program? Write your answer in the box provided. #include…
A: The code along with the screenshot of code and output is given below:
Please find the remark "for question 15" in the given incomplete program. What expression should replace the blank line? When typing your answer, do NOT put spaces where optional spaces may be placed and do NOT include the ; because it is already given.
Attached is the desried sample run and the partially done program
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- class overload { int x; double y; void add(int a , int b) { x = a + b; } void add(double c , double d) { y = c + d; } overload() { this.x 0; %3D this.y = 0; } %3D } class Overload_methods { public static void main(String args[]) { overload obj int a = 2; double b - 3.2; obj.add(a, a); obj.add(b, b); System.out.println(obj.x + } = new overload(); + obj.y); } #3Run the codeJAVA Language Caesar Shift Question: Modify the Caesar class so that it will allow various sized shifts to be used, instead of just a shift of size 3. (Hint: Use an instance variable in the Caesar class to represent the shift, add a constructor to set it, and change the encode method to use it.) import java.util.*; public class TestCipher { public static void main(String[] args) { int shift = 7; Caesar caesar = new Caesar(); String text = "hello world"; String encryptTxt = caesar.encrypt(text); System.out.println(text + " encrypted with shift " + shift + " is " + encryptTxt); } } abstract class Cipher { public String encrypt(String s) { StringBuffer result = new StringBuffer(""); // Use a StringBuffer StringTokenizer words = new StringTokenizer(s); // Break s into its words while (words.hasMoreTokens()) { // For each word in s…Fix this program import java.util.Scanner; public class main { public static void WeShipItBad(String[] args) { int OVERNIGHT_CHARGE = 5; int TWO_DAY_CHARGE = 2; int ECONOMY_CHARGE = 1; Scanner console = new Scanner(System.in); // Scanner object to pass around. // Get item description. String itemDescription = getItemDescription(console); if (itemDescription.equals("")) { System.out.println("Invalid description."); } shipWeight = getShipWeight(scnr); if (shipWeight <= 0.0) { System.out.println(); System.out.println("Invalid weight."); } char shipMethod = getShipMethod(council); shipMethod = Character.toUpperCase(shipMethod); double shipCost = calculateShip(shipWeight, shipMethod); displayResults(itemDescription, shipCost, shipMethod, shipWeight); } public static void getItemDescription(Scanner console) { System.out.println("Enter item description:"); String description =…
- import java.util.Scanner; public class Shady RestRoom 2 { // Modify the code below public static void main (String args[]) { int selection; int price; String result; final int QUEEN = 1, KING = 2, SUITE = 3; final int QPRICE = 125, KPRICE = 139, SPRICE = 165; final String QSTRING = "Queen bed", KSTRING = "King bed"; SSTRING = "Suite with a king bed and pull-out couch"; INVALIDSTRING = "an invalid option"; Scanner in = new Scanner(System.in); System.out.println("\t\n\nMenu\n"); System.out.println("(" + QUEEN + ") " + QSTRING); System.out.println("(" + KING + ") " + KSTRING); System.out.println("(" + SUITE + ") " + SSTRING); System.out.print("Enter Selection (1, 2, or 3) >> "); selection = in.nextInt(); if(selection == QUEEN) { result = QSTRING; price = QPRICE; } else if(selection == KING) { result = KSTRING; price = KPRICE; } else if (selection == SUITE) { result = SSTRING; price = SPRICE; } else { result = INVALIDSTRING; price = 0; } System.out.println("You selected " + result +…import java.util.Scanner;/** This program computes the time required to double an investment with an annual contribution.*/public class DoubleInvestment{ public static void main(String[] args) { final double RATE = 5; final double INITIAL_BALANCE = 10000; final double TARGET = 2 * INITIAL_BALANCE; Scanner in = new Scanner(System.in); System.out.print("Annual contribution: "); double contribution = in.nextDouble(); double balance = INITIAL_BALANCE; int year = 0; // TODO: Add annual contribution, but not in year 0 do { year++; double interest = balance*(RATE/100); balance = (balance+contribution+interest); } while(balance< TARGET); System.out.println("Year: " + year); System.out.printf("Balance: %.2f%n", balance); }}public class sample{public static int x = 100;public static int y = 150; }public class newspaper :sample{new public static int x = 1000;static void Main(string[] args){console.writeline(sample.x + " " + sample.y + " " + x);}} 100 150 1000 1000 150 1000 100 150 1000 100 150 100
- Case Diagram and UML Class Diagram for this java code : (Below the code give some constructive critiques about the UML class diagram)…. Thanks import java.util.*; public class BeverlyBreads{public static void main(String[] args){Scanner input = new Scanner(System.in); //Array for breads String[] breads = new String[5]; //Bread choices breads[0] = "White Bread"; breads[1] = "Wheat Bread"; breads[2] = "Rye Bread"; breads[3] = "Pumpernickel Bread"; breads[4] = "Baguette"; //Prices for the breads double[] prices = new double[5]; prices[0] = 2.99; prices[1] = 3.49; prices[2] = 3.99; prices[3] = 4.49; prices[4] = 4.99; //Customer's Name System.out.println("Enter customer's name: "); String name = input.nextLine(); //Customer's Phone Number System.out.println("Enter customer's phone number: "); String phoneNumber = input.nextLine(); //Bread Selection System.out.println("Which bread would you like to order?"); for(int i = 0; i < breads.length; i++) { System.out.println(breads[i] + "…mport java.util.Scanner; public class ParkingCharges { // function to calculate the basic charge using the asked hours static double getBasicCharge(int hours) { if (hours >= 7 && hours <= 8) return 5.50; else if (hours >= 5 && hours <= 6) return 4.50; else if (hours >= 2 && hours <= 4) return 4.00; return 3.00; } // function to return the amount to subtract based on local living and OAP static double getDiscount(String isLocal, String isOAP) { if (isOAP.equals("Yes") && isLocal.equals("Yes")) return 2.0 + 1.0; else if (isOAP.equals("Yes")) return 2.0; else if (isLocal.equals("Yes")) return 1.0; return 0; } public static void main(String[] args) { // create a new Scanner object Scanner sc = new Scanner(System.in); // prompt the user to ask if they are disabled…import java.util.Scanner;public class Resto{public static void main (String[] args){//initialization and declarationScanner input = new Scanner (System.in);String message;int Option1;int Option2;int Quantity;int TotalBill;int Cash;int Change;final int SPECIALS = 1;final int BREAKFAST = 2;final int LUNCH = 3;final int SANDWICHES = 4;final int DRINKS = 5;final int DESSERTS = 6;//For the Special, Breakfast, Lunch Optionsfinal int Meals1 = 11;final int Meals2 = 12;final int Meals3 = 13;final int Meals4 = 14;//First menu and First OptionSystem.out.println("\t Welcome to My Kitchen ");System.out.println("\t\t SPECIALS");System.out.println("\t\t [2] BREAKFAST MEALS");System.out.println("\t\t [3] LUNCH MEALS");System.out.println("\t\t [4] SANDWICHES");System.out.println("\t\t [5] DRINKS");System.out.println("\t\t [6] DESSERTS");System.out.println("\t\t [0] EXIT");System.out.print("Choose an option ");Option1 = input.nextInt();//first switch case statementsswitch(Option1){case…
- * CENGAGE MINDTAP Programming Exercise 3-6 Instructions BookstoreCredit.java + 1 import java.util.Scanner; 2 public class BookstoreCredit { To encourage good grades, Hermosa High School has decided to public static void main (String args[]) { // Write your code here 3 award each student a bookstore credit that is 10 times the student's 4 grade point average. 5 } 6 public static void computeDiscount(String name, double gpa) { // Write your code here } In other words, a student with a 3.2 grade point average receives a 8 $32.0 credit. 10 Create an application that prompts a student for a name and grade 11 } point average, and then passes the values to a method ( 12 computeDiscount ) that displays a descriptive message. The message uses the student's name, echoes the grade point average, and computes and displays the credit. An example of the program is shown below: Enter your name >> John Enter your gpa >>3.4 John, your GPA is 3.4, so your credit is $34.0 Grading Write your Java code in…public class Main{ public static void main(String args[]) { Main m = new Main(); m.go(); } public void go() { Customer c = new Customer("Tom", "Smith"); Order o = new Order(c); o.addItem(new Item("Greeting Card", 1.50, 1)); o.addItem(new Item("Baseball Glove", 54.00, 1)); o.addItem(new Item("Notebook", 2.50, 3)); System.out.println(o); }}import java.util.Scanner;public class MP2{public static void main (String[] args){//initialization and declarationScanner input = new Scanner (System.in);String message;int Option1;int Option2;int Quantity;int TotalBill;int Cash;int Change;final int SPECIALS = 1;final int BREAKFAST = 2;final int LUNCH = 3;final int SANDWICHES = 4;final int DRINKS = 5;final int DESSERTS = 6;//For the Special, Breakfast, Lunch Optionsfinal int Meals1 = 11;final int Meals2 = 12;final int Meals3 = 13;final int Meals4 = 14;//First menu and First OptionSystem.out.println("\t Welcome to My Kitchen ");System.out.println("\t\t SPECIALS");System.out.println("\t\t [2] BREAKFAST MEALS");System.out.println("\t\t [3] LUNCH MEALS");System.out.println("\t\t [4] SANDWICHES");System.out.println("\t\t [5] DRINKS");System.out.println("\t\t [6] DESSERTS");System.out.println("\t\t [0] EXIT");System.out.print("Choose an option ");Option1 = input.nextInt();//first switch case statementsswitch(Option1){case (SPECIALS):message…