Skip to content

In this repository are located solutions to tasks written in the Java programming language on the core (mathematics) programming topics. A more detailed description of the project structure and the conditions of the tasks can be found in the file README.md .

Notifications You must be signed in to change notification settings

KostiantynLuhovyi/java-core.tasks-solution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

java-core.tasks-solution

In this repository are located solutions to tasks written in the Java programming language on the core programming (mathematics) topics.

Names of packages with classes that solve a task have a brief description of the task to be solved. The description of the tasks to be solved can be read in the comments in the Main class, which is in each package with the tasks to be solved. Also in the file README.md.

Many of functional solutions are implemented in the java-helper library classes. A detailed description of the functional contained in the library "java-helper" and used for solving tasks can be found in the repository by the link: https://github.com/LugowoyKonstantin/java-helper.tasks-solution

If you have any questions about this repository or the solution of the tasks in it, you can contact the following contacts:

email: kostya.lugowoy@gmail.com
skype: Lugowoy Konstantin
linkedin: Konstantin Lugowoy
facebook: Konstantin Lugowoy


The package name and description of the solved task that are contained in the root package com.lugowoy.tasks :
(124)

  • calculateAreaAndLengthOfCircle
    • Write a program that prompts the user to enter the radius of the circle, and then finds the area and the lengthRoom of the circumference. The number Pi to set the program as a real constant.
  • calculateArithmeticMeanOfNumbers
    • Write a program that finds the arithmetic mean of the three real numbers.
  • calculateCostOfCallWithPerSecondBilling
    • The user enters the start time and the end time of the telephone conversation from the keyboard (hours, minutes and seconds). Calculate the cost of the call, if the cost of the minute is 15 cents, taking into account per second charging.
  • calculateDistanceBetweenMostDistantPointsOnLine
    • Write a program for entering three numbers, as the coordinates of points on a line and calculate the distance between the most distant from each other.
  • calculateDistanceFromPointToSingleCircleWithCenterAtGivenPoint
    • Write a program that enters the coordinates M (x, y) and C (x, y) of points on the plane, and prints the result of the distance from the point M (x, y) to the unit circle centered at point C (x, y).
  • calculateDistanceFromPointToStraightLineInPlane
    • Write a program that inputs the real coordinates (x, y) and (a, b) of two points onto a plane, and calculate the distance from the point M (x, y) to the straight line OA, where O is the start origin of coordinates, and the point A is different from 0.
  • calculateHeightOfSatellitesOrbitAboveEarthsSurface
    • Calculate the height of the satellite's orbit above the Earth's surface.
  • calculateHowManyHoursLeftForUserToBeAtWork
    • Calculate how many hours left for the user to be at work.
  • calculateHowManyMoviesWillFitOnUSBFlashDrive
    • The user enters from the keyboard the volume of the USB flash drive in gigabytes. Calculate how much it will fit the size of films entered by the user.
  • calculateHowMuchMoneyUserWillReceiveAtEndOfTermOfDeposit
    • Calculate how much money user will receive at end of term of deposit.
  • calculatePercentageOfStudentsWhoDidNotDoTheirHomework
    • The teacher enters from the keyboard the number of students who submitted homework and the number of those who did not pass. Calculate how many percent of students who did not pass their homework from the total number of students.
  • calculatePercentageRatioOfDifferentNumberVariantsAmongRandomlyGeneratedNumbers
    • To guess randomly 100 integers in the range from -100 to 100. Calculate the percentage of positive numbers, the percentage of negative numbers and the percentage of zeros. Calculate the percentage of even numbers and the percentage of odd numbers.
  • calculateRootOfLinearEquation
    • Write a program that finds the root of the linear equation ax + b = 0.
  • calculateTotalCostOfOrderingLaptopAtDiscount
    • The user enters from the keyboard the cost of one laptop, their number and percentage discount. Calculate the total cost of the order.
  • calculateVelocityWithWhichYouNeedToGoToAirport
    • The user enters from the keyboard the distance to the airport (in kilometers, there may be a real value) and the time for which you need to reach (in minutes). Calculate the speed (km / h) with which you need to go.
  • calculatingFibonacciNumbers
    • Calculating Fibonacci numbers.
  • calculatingNumberProductsOfPurchasedForCertainSum
    • How many products can be purchased at the cost of Y on X UAH and how many receive the change money?
  • calculatingValueAndDerivativeOfPolynomial
    • Calculating the value and derivative of a polynomial based on the elements of the array.
  • calculationOfCoordinatesOfBodyCastAtAngleToHorizon
    • Write a program for calculating the coordinate time at the specified time body, thrown at an angle to the horizon. We assume that the mass of the body m is known, the initial velocity V, the angle a, under which the body is thrown to the horizon. In addition, we believe that the body acts as an air resistance force, modulo proportional to the speed of the body and directed opposite to the direction of flight of the body.
  • calculationOfExponent
    • Calculation of the exponent.
  • calculationOfIdealWeightForGrowth
    • The program for calculating the ideal weight for growth. Enter the height and weight, output a message about how much you need to gain or lose kg (ideal weight = height - 110).
  • calculationOfMonthlyPaymentsOnDeposit
    • Write a program that asks the user enter sum cash deposit , as well as a percentage per yearly, which pays the bank. Determine the amount of money paid by the bank in the current month.
  • calculationOfPiNumberOnBasisOfFourierSeries
    • Calculation of the Pi number on the basis of the Fourier series.
  • calculationOfPiNumberOnBasisOfModifiedMonteCarloMethod
    • Calculation of the Pi number on the basis of the modified Monte Carlo method.
  • calculationOfPiNumberOnBasisOfProductOfNumbers
    • Calculating the number Pi on the basis of the product of numbers.
  • calculationOfVariousValuesForBodyFlyingInAtmosphere
    • Calculate the trajectory of the motion of a body thrown at an angle to the horizon, provided that the body, in addition to the force of gravity, also acts on the strength of air resistance. Assume that in the atmosphere, depending on the height above the surface, the force of air resistance is different: in the first lower layer it is proportional to the square of the velocity of the body (and is directed against the velocity vector), in the second central layer, the air resistance force is proportional to the speed of the body, and in the third, the upper layer of the atmosphere, the force of air resistance is absent.
  • calculationPercentageOfSum
    • Write a program that finds the percentage P of the sum of S.
  • carryOutCyclicShiftOfEnteredNumberByCertainNumberOfDigits
    • Carry out a circular shift to the left of the entered number by N digits (for example, by shifting the number 12345 to the left by 3 digits, the number is 45123).
  • checkCorrectnessOfEnteredTimeData
    • Enter the current time (number of hours, minutes, seconds) from the keyboard. Check the correctness of the entered values.
  • checkMultiplicityOfNumber
    • Write a program to check the multiplicity of the number X by the number Y (both numbers are entered from the keyboard).
  • checkMultiplicityOfNumberByThreeNumbers
    • Enter the number and determine whether it is a multiple of 3, 5, and 7 at the same time.
  • checkThatAllDigitsOfNumberAreArrangedInAscendingOrder
    • Enter the number from the keyboard. Check that all the digits of this number are in a non-decreasing order (for example, the number 11299 corresponds to the job, and the number 22044 is not).
  • checkWhetherThereIsInEnteredNumbersAreSameNumbersInRow
    • Check whether there is in the entered numbers are the same numbers in a row.
  • constructionOfComplexNumberToIntegerDegree
    • Construction of a complex number to the integer degree.
  • convertingDegreesTemperatures
    • Write a program that converts a specified number of degrees Celsius to degrees Fahrenheit, Kelvin, Reaumur and Delisle. Then realize the convert from degrees Fahrenheit, Kelvin, Reaumur and Delisle to degrees Celsius.
  • convertKilometersToMilesOfSeaAndLand
    • Write a program that converts kilometers to miles of land and sea.
  • convertRealNumberInTonsAndWithdrawTonsKilogramsAndGrams
    • The user enters the mass in tons (real number) from the keyboard. Output separately the number of tons, kilograms, gram (for example, enter 126.456789t - get and output 126t 456kg 789g).
  • convertTimeInSecondsToCorrespondingTimeOfStandardView
    • The user enters the time in seconds from the keyboard. Convert this value in days, hours, minutes and seconds.
  • convertUAHToOthersCurrencies
    • Write a program that allows the user to enter the number using the keypad UAH, and convert it into USD, EUR and RUB.
  • countHowManyFloppiesAreNeededToTransferMovieToAnotherComputer
    • The user enters from the keyboard the volume of one movie in gigabytes. Count how many floppies are needed to transfer the movie to another computer (the size of the floppy disk is considered equal to 1.44 MB).
  • countNumberOfOccurrencesOfMaximumNumber
    • Enter numbers. Count the number of occurrences of the maximum number in the integer array.
  • cyclicallyShiftDigitsOfFiveDigitNumber
    • Enter a five-digit number and shift it cyclically to the right by N digits.
  • deduceSumOfIntegerAndFractionalPartsOfTwoEnteredNumbers
    • The user enters two real numbers from the keyboard. To deduce on the screen the sum of the integer and fractional parts of two numbers.
  • determineAffiliationOfCertainValueToConcreteInterval *Write a program that displays messages about the belonging of some value of k to the intervals (-10k, 0], (0, 5], (5, 10], (10, 10k].
  • determineDigitOfNumberAndTheirSum
    • An integer of any length is entered from the keyboard. Determine the number of digits in it and their sum.
  • determineHowMuchTimeIsLeftBeforeMidnight
    • The user enters the time in seconds from the beginning of the day from the keyboard. Determine how much time (hours, minutes and seconds) is left until midnight.
  • determineHowMuchTimeOnRoadWasMarathonRunner
    • The marathon runner has passed S kilometers with a speed of V meters per second (distance and speed are entered from the keyboard). Determine how much time he was on the road (hours, minutes, seconds)?
  • determineNumberInWhichNumberOfDifferentDigitsIsMinimal
    • Determine the number in which the number of different digits is minimal. If there are several of them, then print the first number.
  • determineNumberIsPolindrome
    • Determine that the number of palindromes, whose values in the forward and reverse order are the same.
  • determineNumberOfDigitsInNumber
    • Enter an integer (no more than 4 digits!). Determine the number of digits in it.
  • determineNumbersWithEqualNumberOfEvenAndOddDigits
    • Determine numbers with an equal number of even and odd digits.
  • determineNumberThatContainsOnlyDifferentDigits
    • Determine a number consisting only of different digits. Print the first found number.
  • determinePeriodOfDecimalFractionForFirstTwoPositiveIntegersLocatedInRow
    • Determine the period of the decimal fraction p = m / n for the first two positive integers n and m located in a series.
  • determineSecondLargestNumber
    • Enter three numbers and define the second largest number.
  • determineSecondNumberOfPalindrome
    • Determine the number of the palindrome. If it is not the only one, then take the second one.
  • determineThatNumberIsHappy
    • Determine that the number is "happy".
  • determineThatTicketIsHappy
    • To determine that the ticket is happy.
  • determineTimeForPersonToRetire
    • Enter the keyboard sex and age of the person. Determine whether it's time for him to retire.
  • determineTimeForWhichMovieIsDownloaded
    • The user enters from the keyboard the size of one movie in gigabytes (real value) and the speed of the internet connection in bits per second. Determine for what time (hours, minutes and seconds) the movie is downloaded.
  • determineWhatIsEnteredCharacter
    • Enter a symbol from the keyboard. Determine what it is: a number, letter or punctuation mark.
  • determineWhetherEnteredNumberIsPrime
    • An integer is entered from the keyboard. Determine whether it is simple. A prime number is divisible without a remainder by only 1 and itself.
  • determineWhetherFiveDigitNumberIsPalindrome
    • Enter a five-digit number from the keyboard and determine if it is a palindrome. (ie, it reads the same in both directions, for example, 12321 is a palindrome, and 12345 is not a palindrome).
  • determineWhetherIntroducedNumberHasRealPart
    • Determine whether the introduced number has a real part. For example, the numbers 3.14 and 2.5 have a real part, and the numbers 5 and 10.0 do not.
  • determineWhetherLineIsParallelToOrdinateOrToAbscissa
    • Determine whether a particular straight line of the ordinate axis is parallel or the abscissa axis. The straight line is given by two points.
  • determineWhetherNumberBelongsToRangeOfNumbers
    • Enter a number on the keyboard and check if this number belongs to the range from N to M (inclusive).
  • determineWhetherPointBelongsToRectangle
    • The user enters the coordinates of the upper left, and the lower right corner of the rectangle, as well as the coordinates of the point (X, Y) in the Cartesian coordinate system. Does the point belong to this rectangle?
  • determineWhetherValueBelongsToCertainInterval
    • Determine if K belongs to a certain interval (n,m],[n,m),(n,m),[n,m].
  • determineWhichResistorToUseSoThatTotalResistanceOfCircuitIsMinimal
    • Suppose that the area of the electrical circuit must consist of two blocks, in each of which two parallel resistors are located. The blocks are connected in series. There are three resistors of known resistance that can be freely shifted between blocks, and one main resistor, which must be in the second block. It is necessary to determine which resistor is inserted into the second block in addition to the main one, so that the total resistance of the circuit section is minimal.
  • displayArmstrongNumbersInSpecifiedRange
    • Display on the screen all Armstrong numbers in the range from 0 to 10.000.000.
  • displayModuleEnteredNumber
    • Display module the entered number.
  • displayParallelepipedSkeleton
    • Display the frame of a parallelepiped with the dimension AxBxC.
  • displayPythagoreanMultiplicationTable
    • Display the multiplication table (Pythagoras table).
  • elementaryImplementationOfDynamicList
    • Elementary implementation of a dynamic list.
  • encodeAndDecodeTwoCharactersInSuitableIntegerVariable
    • Encode and decode the two characters into a suitable integer variable.
  • exchangeCentralNumberOfTwoNumbers
    • Enter from the keyboard two three-digit numbers and change their central numbers.
  • exchangePlacesTwoVariablesWithAndWithoutUseOfThirdVariable
    • Exchange the values of two variables, first using an additional third variable, and then - without third variable.
  • findAllRootsOfQuadraticEquation
    • Write a program that introduces positive real numbers for the quadratic equation ax² + bx + c = 0. Find both roots of this equation.
  • findMaximumValueAmongFourVariablesUsingTernaryOperator
    • Find the maximum value among the 4 variables using the ternary operator.
  • findNumbersThatContainOnlyEvenNumbers
    • Find the number of digits in which go in the order of strict ascending. If such numbers are somewhat to display the first.
  • findNumbersThatContainOnlyEvenNumbers
    • Find numbers that contain only even numbers.
  • flipNumberDownSoThatDigitsAreArrangedInReverseOrder
    • An integer of any length is entered from the keyboard. It is necessary to turn this number around, i.e. the numbers should be in the reverse order (for example, enter the number 1234 - the result will be 4321).
  • identifyTwoIdenticalNumbers
    • Enter three numbers and define two of the same number of them.
  • implementElementaryConsoleCalculator
    • Implement a calculator. We input 2 any real numbers in the variables a and b. You need to display the menu with the items: 1) a + b ; 2) a - b ; 3) a * b ; 4) a / b ; 5) a % b ; If you select the appropriate menu item, the result of the calculation is output (there should be a check of division by 0!)
  • operationsWithSeparateDigitsOfNumber
    • Enter a four-digit number, and calculate the sum of the first and the third digit and the difference between the second and fourth digits.
  • outputAllNumbersToWhichEnteredNumberIsDividedWithoutRemainder
    • An integer is entered from the keyboard. Display all numbers on which the entered number is divided without a remainder. For example, for 60 such numbers will be 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60.
  • outputNumbersThatAreDivisibleByThreeAndNine
    • Output numbers that are divisible by 3 and 9 .
  • outputPrimeNumbersInCertainRange
    • Write a program that displays all the prime numbers in the range from 2 to 10.000.000.
  • outputToConsoleTemperatureConformityOfCelsiusAndFahrenheit
    • The program prints a table of temperature correlations for Celsius and Fahrenheit in the specified range.
  • outputVoiceThatIsEmittedByAnimal
    • Write a program that prompts the user to select an animal from the list (1 - cat, 2 - dog, etc.), and in response shows what voices the selected animal makes. There should be at least 10 animals on the list.
  • printAllThreeDigitNumbersThatDoNotHaveSameDigits
    • Output all three-digit numbers, in the decimal notation of which there are no identical digits.
  • printDayOfWeekAccordingToNumber
    • Write a program that prompts the user to enter the day of the week number, and in response displays the name of that day (for example, 6 is Saturday). Solve using if and switch.
  • printEvenAndOddNumbers
    • Print even and odd numbers.
  • printFilledMatrix5x5FromLeftToRight
    • Write a program that displays numbers from 1 to 25 as a 5x5 matrix from left to right.
  • printFilledMatrix5x5FromTopToBottom
    • Write a program that displays numbers from 1 to 25 as a 5x5 matrix from top to bottom.
  • printLongestNumber
    • Find the longest number. Print the found number and their length.
  • printMaxAndMinNumber
    • Print max and min value number.
  • printNumbersInAscendingOrderOfLength
    • Sort and print the numbers in ascending order of their lengths.
  • printNumbersInDescendingOrderOfLength
    • Sort and print the numbers in descending order of their lengths.
  • printNumbersWhoseLengthIsGreaterThanAverage
    • Print numbers whose length is greater than the average.
  • printNumbersWhoseLengthIsLessThanAverage
    • Print numbers whose length is less than the average.
  • printShortestNumber
    • Find the shortest number. Print the found number and their length.
  • printToNameOfMonthCorrespondingToGivenNumber
    • Enter the number from 1 to 12. Output to the console the name of the month corresponding to the given number. (Make sure that the numbers are entered correctly).
  • printToWelcomeScreenCorrespondingToEnteredTime
    • The time (hours and minutes) is entered - the program displays a greeting corresponding to the entered time (for example, entered 15 hours 6 minutes - the greeting "good day" is displayed).
  • productOfSquareMatrices
    • Product of square matrices.
  • raiseNumberToPower
    • Raise the number entered in the power.
  • removeCentralDigitNumberOfThreeDigitsNumber
    • Entered from the keyboard three-digit number and remove it from the central digit.
  • reverseEntryThreeDigitNumber
    • Key in three-digit number and "reverse" it.
  • roundNumberToTwoDecimalPlaces
    • The user enters a fractional number from the keyboard. Round it up to two decimal places and display it.
  • scalarAndVectorProductOfVectors
    • Scalar and vector product of vectors.
  • searchNthPrimeNumber
    • Realization of the search n-th prime number.
  • showAllEightDigitNumbersOfNumbersInWhichDoNotRepeat
    • Display on the screen all eight-digit numbers, the numbers in which do not repeat. These numbers must be divisible by 12345 without any residue. Show the total number of numbers found.
  • showIsoscelesTriangleFilledWithStars
    • Show an isosceles triangle on the screen (the user enters the height). Then do the same, but that the figure inside was empty (only the outline remains).
  • showNumbersAndTotalNumberOfAllSixDigitHappyTickets
    • Show the numbers and the total number of all the happy tram tickets with six-digit numbers.
  • showRectangleConsistingOfStars
    • Show on the screen a rectangle with the size MxN, consisting of stars. Then do the same, but that the figure inside was empty (only the frame remains).
  • showRhombusFilledWithStars
    • Write a program that displays a rhombus (the lengths of diagonals of a rhombus are the same in value, but can be equal to any number). Then do the same, but that the figure inside was empty (only the outline remains).
  • solutionOfEquationBySuccessiveIterations
    • The solution of an equation of the form x = f (x) by the method of successive iterations.
  • transposeOfSquareMatrixRepresentedAsTwoDimensionalArray
    • Transpose of a square matrix represented as a two-dimensional array.
  • writeProgramForCalculatingSpeedOfCarOnRouteByCertainCondition
    • Write a program to calculate the speed of the car on the route if it is known that the car is moving at a constant known speed between points A and B, the distance between which is also known. Then the car moves from point B to point C (the distance between points is known) with a constant but unknown speed. It must be calculated if the average speed of the car on the route from point A to point C (via point B) is known.
  • writeProgramThatCalculatesFactorialOfEnteredNumber
    • Write a program that calculates the factorial of the entered number.
  • writeProgramThatDeducesSetOfSolutionsToEquation
    • Write a program that introduces three integers and prints the set of solutions of equation ax² + bx + c = 0;
  • writeProgramThatGeneratesMultiplicationTable
    • Write a program that generates a multiplication table.
  • writeProgramToCalculateCoordinatesOfBallThrownAtArbitraryTime
    • The elastic ball is thrown at an angle to the horizon at some initial velocity. When the ball falls on a flat horizontal surface, there is an elastic beating, so that the horizontal component of the speed of the ball does not change, and the vertical component changes to the opposite one. It is necessary to write a program that calculates the position (coordinates) of the ball at any time.
  • writeProgramUsingBernoulliScheme
    • Write a program using the Bernoulli scheme.
  • writeSolutionOfTrigonometricEquationOfCertainType
    • Write a solution of a trigonometric equation of the form : acos(x) + bsin(x) = c

About

In this repository are located solutions to tasks written in the Java programming language on the core (mathematics) programming topics. A more detailed description of the project structure and the conditions of the tasks can be found in the file README.md .

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages