
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
thumb_up100%
Write Java source code to take an integer n and returns the sum of all odd positive integers less than or equals to n. Please implement a sumOddo method for major functionality and a main method with input data for testing cases.
Please pay attention to the neat coding style in Java, including grammar, indentations, naming of variables and methods, and comments.
a) Conduct an experimental study regarding the running time of your Java code in nanoseconds. Please use excel to generate a chart/figure on the evaluation results.
b) Analyze the time complexity and space complexity of your source code using asymptotic analysis.
c) Is there a way that your algorithm can be further improved regarding time complexity and space complexity? Why or why not?
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Step 1: Introduction
VIEW Step 2: JAVA Code
VIEW Step 3: OUTPUT
VIEW Step 4: Question (a)
VIEW Step 5: Question (b)
VIEW Step 6: Question (c)
VIEW Step 7: Result after improvements
VIEW Step 8: Detailed Explanation of Iterative Approach
VIEW Step 9: Detailed Explanation of Formula-based Approach
VIEW Solution
VIEW Trending nowThis is a popular solution!
Step by stepSolved in 10 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write Four java programs (Snack.java, FruitSnack.java, SaltySnack.java, and OrderSystem.java. A Word document that includes a test table with test case #, input, expected output, actualoutput, and pass/fail columns. There should be at least 3 test cases. Make sure to includetest cases that validate data. Include a screen capture of running each test case. Include header comments that include your name, date, and description of the program. Include body comments. (1) There will be a Snack class with following attributes: id (combination of numbers and letters), size(values S, M, or L), and price(2) There will be two child classes FruitSnack and SaltySnack with the following additional attributes:o FruitSnack: It includes citrus fruit indication (value of this variable of is true or false)o SaltySnack: It includes nut snack indication (value of this variable of is true or false)(3) The Snack class hierarchy must provide the following functionality:• On creation, a snack instance must be…arrow_forwardWrite a Java program that can simulate a simple calculator, using the Java console as the exclusive input and output device. That is, each input to the calculator, be it a number, like 12.34 or 1034, or an operator, like + or=, can be done on a separate line. After each such input, you should output to the Java console what would be displayed on your calculator.arrow_forwardYou are given the following JavaDoc and asked to write the test cases for this method. You do not need to write the java code (JUnit); instead, you need to fill in the table with the inputs you choose for testing and justify your selection. You need to write only seven different/distinct test cases and explain why you have chosen the inputs for these cases. Note that no redundant or duplicate test cases are acceptable.arrow_forward
- Complete documentation and a Java implementation are needed. Make some kind of code that embeds your name in a red circle with a blue border.arrow_forward3. Provide an example of how to achieve encapsulation in Java.arrow_forwardCreate a multiplication-and-division calculator's Java interface. It needs ON, OFF, and clear buttons.arrow_forward
- Write in Java a code give out what is on the image. Essentially write in the main function so that it prints what is in the image. Im stuck at that part it would be much appreciated if you could help. package javaapplication31; import java.util.Random;import java.util.Scanner;/**** @author */public class JavaApplication31 {String name;/*** @param args the command line arguments*/public static void main(String[] args) {int totalScore = 300;int itrcount =12;int reward;char direction;int x = 0;int y = 0;System.out.println(reward());System.out.println(inputDirection());}public static void displayInfo(int x, int y, int itrCount, int totalScore){x = 0;y = 0;itrCount = 0;totalScore =300;System.out.println("");}public static boolean doesExceed (int x,int y, char direction){return (y > 4 && Character.toLowerCase(direction) == 'u' || x < 0 && Character.toLowerCase(direction) == '1'||y < 0 && Character.toLowerCase(direction) == 'd' || x > 4 &&…arrow_forwardhelp me answer this java languagearrow_forwardIn java and UML diagram, Please show output and comment code out Source file: Each public class must be contained in a separate Java source file. Only one source file will have a main() method and this source will be named BlackjackGameSimulator.java. Other source/class names are up to you following the guidelines specified so far in the course. The format of the Java source must meet the general Java coding style guidelines discussed so far during the course. Pay special attention to naming guidelines, use of appropriate variable names and types, variable scope (public, private, protected, etc.), indentation, and comments. Classes and methods should be commented with JavaDoc-style comments (see below). Please use course office hours or contact the instructor directly if there are any coding style questions. JavaDocs: Sources should be commented using JavaDoc-style comments for classes and methods. Each class should have a short comment on what it represents and use the @author…arrow_forward
- i would like help in JAVA using eclipse software. code with comments would be wonderful. thanksarrow_forwardIn the chapter materials and the conference we saw and discussed the various Quotent programs that started with a fragile program design and made it more robust in implementation. It didn't finish the job, however. In this assignment, we take the same concept and make a robust Quotent program (to be named MyDivision.java). As before, we will ask for two integers and divide them to obtain the result; however, this time we will check for both division by zero and input type mismatch problems. Don't explicitly check the content of the input items, let Java's default handling manage the generation of the Exceptions (i.e., don't use the throw syntax, however you may use the throws syntax). Detect both of these conditlons and provide a mechanism for the user to make any necessary corrections before continuing the program to completion. Here is your starting code: /* Instructions:Don't test for zeros or non-numeric strings on your input.Let Java throw its built-in exceptions. Catch…arrow_forwardthe following code is centered around data collection, filtering, and using the Singleton pattern in Java, which is all part of a mockup "student information management system", with its purpose being making mockup new student accounts. I've been having issues using the software “dbeaver” for making java projects. Please organize the below code into an executable project “simulation.student” and given step by step instruction as to how this was done Address.java public class Address {private String _city;private String _state;private String _streetName; // Newprivate int _streetNumber; // Newprivate int _apartmentNumber; // New public Address(String city, String state, int zip, String streetName, int streetNumber, int apartmentNumber) {setCity(city);setState(state);setZip(zip);setStreetName(streetName);setStreetNumber(streetNumber);setApartmentNumber(apartmentNumber);} public String getCity() {return _city;} public void setCity(String city) {_city = city;} public String getState()…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education