求这段c语言代码换成java代码⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯

#include

#include

using namespace std;

struct jewelry {

int price;

int volume;

bool operator < (const jewelry &A) const {

return price > A.price;

}

}buf[101];

int main() {

int v, n, i, ans, ids;

while(~scanf("%d", &v) && v) {

scanf("%d", &n);

for(i=0; i scanf("%d%d", &buf[i].price, &buf[i].volume);
sort(buf, buf+n);
ids = 0;
ans = 0;
while(v>0 && ids if(v>=buf[ids].volume) {

v -= buf[ids].volume;

ans += buf[ids].price * buf[ids].volume;

} else {

ans += v * buf[ids].price;

v = 0;

}

ids ++;

}

printf("%d\n", ans);

}

return 0; 图片说明

 class jewelry {  
    public int price;  
    public int volume;  
    boolean compareto (jewelry A) {  
        return this.price > A.price;
}  
static jewelry[] buf = new jewelry[101];  
void main() {  
    int v, n, i, ans, ids;
        Scanner in = new Scanner(System.in);
    while(in.hasNextInt()) {
            v = in.nextInt();
        n =  in.nextInt();  
        for(i=0; i<n; i++)  
                {
                    buf[i] = new jewelry();
            buf[i].price= in.nextInt();
                        buf[i].volume = in.nextInt();  
                }
        sort(buf, buf+n);
        ids = 0;  
        ans = 0;  
        while(v>0 && ids<n) {  
            if(v>=buf[ids].volume) {  
                v -= buf[ids].volume;  
                ans += buf[ids].price * buf[ids].volume;  
            } else {  
                ans += v * buf[ids].price;  
                v = 0;  
            }  
            ids++;  
        }
        System.out.println(ans);  
    }  
    return 0; 
}

我不敢休息,因为我没有存款;

我不敢说累,因为我没有成就;

我不敢偷懒,因为我还要生活;

我能放弃选择,但是我不能选择放弃。

所以坚强,拼搏是我唯一的选择。

世上没有一件工作不辛苦,

没有一处人事不复杂。

即使你再排斥现在的不愉快,

光阴也不会过得慢点。

所以不要随意发脾气,谁都不欠你的。

要学会低调,取舍间必有得失,

不用太计较。......
答案就在这里:我不敢!⋯⋯⋯⋯致所有拼搏的年輕人
----------------------Hi,地球人,我是问答机器人小S,上面的内容就是我狂拽酷炫叼炸天的答案,除了赞同,你还有别的选择吗?

能说清楚需求是要实现什么吗?

java导入包 ,导入源文件:
package org.noc,,,,
import java.io,,,,,

java main:
public static void main(args []){
}

scanf = println

    public static void sort(jewelry[], int n)
    {
        for (int i = 0; i < n - 1; i++)
        {
            for (int j = 0; j < n - 1; j++)
            {
                if (jewelry[j].compareto[j + 1])
                {
                    jewelry t = jewelry[j];
                    jewelry[j] = jewelry[j + 1];
                    jewelry[j + 1] = t;
                }
            }
        }
    }