CSP 2017.9 first question soy sauce Java code

Source: Internet
Author: User

Problem description
Xiao Ming takes n yuan to buy soy sauce. Soy sauce 10 yuan a bottle, merchants to promote, each buy 3 bottles to send 1 bottles, or 5 bottles per buy to send 2 bottles. How many bottles of soy sauce can I get, xiaoming?
Input format
The first line of input contains an integer n, which indicates the amount of money that xiaoming can use to buy soy sauce. n is an integer multiple of 10, and N does not exceed 300.
Output format
Output an integer indicating how many bottles of soy sauce The xiaoming can get.
Sample input

Sample Output 5

Sample Description
40 yuan into 30 yuan and 10 yuan, respectively, to buy 3 bottles and 1 bottles, of which 3 bottles to send 1 bottles, a total of 5 bottles.
Sample input

Sample Output

Sample Description
80 yuan into 30 yuan and 50 yuan, respectively, to buy 3 bottles and 5 bottles, of which 3 bottles to send 1 bottles, 5 bottles to send 2 bottles, a total of 11 bottles.

package com.

cavellchance.learning;

Import Java.util.Scanner;
        public class Buysomesauce {public static int bigsale (int m) {int bottle5 = M/50;
        int bottle5left = m% 50;
        int bottle3 = BOTTLE5LEFT/30;
        int bottle3left = bottle5left% 30;
        int bottle1 = BOTTLE3LEFT/10;
        int bottles = Bottle5 * 7 + bottle3 * 4 + bottle1 * 1;
    return bottles;
        public static void Main (String args[]) {int ' money = 0;
        Scanner Scanner = new Scanner (system.in);
        if (Scanner.hasnextint ()) {money = Scanner.nextint ();
    } System.out.println (Bigsale (money)); }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.