Java™ How to Program ( Deitel - Deitel) - Phần 12

Tham khảo sách 'java™ how to program ( deitel - deitel) - phần 12', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | testing numbers much larger than 1000. Display the results. An integer is said to be prime if it is divisible by only 1 and itself. For example 2 3 5 and 7 are prime but 4 6 8 and 9 are not. a. Write a method that determines whether a number is prime. b. Use this method in an application that determines and displays all the prime numbers less than 10 000. How many numbers up to 10 000 do you have to test to ensure that you have found all the primes c. Initially you might think that n 2 is the upper limit for which you must test to see whether a number is prime but you need only go as high as the square root of n. Why Rewrite the program and run it both ways. Estimate the performance improvement. Write a method that takes an integer value and returns the number with its digits reversed. For example given the number 7631 the method should return 1367. Incorporate the method into an application that reads a value from the user and displays the result. The greatest common divisor GCD of two integers is the largest integer that evenly divides each of the two numbers. Write a method gcd that returns the greatest common divisor of two integers. Incorporate the method into an application that reads two values from the user and displays the result. Write a method qualitypoints that inputs a student s average and returns 4 if the student s average is 90100 3 if the average is 8089 2 if the average is 7079 1 if the average is 6069 and o if the average is lower than 60. Incorporate the method into an application that reads a value from the user and displays the result. Write an application that simulates coin tossing. Let the program toss a coin each time the user chooses the Toss coin menu option. Count the number of times each side of the coin appears. Display the results. The program should call a separate method flip that takes no arguments and returns false for tails and TRue for heads. Note If the program realistically simulates coin tossing each

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.