我如何获取通过in.nextInt()输入的整数;和in.nextDouble();并将这两者相乘?

时间:2015-07-23 02:19:00

标签: java

代码:

public static void main (String[] args)
{

    //last name,first name
    Scanner in = new Scanner(System.in);
    System.out.print(" Enter the name (Last, First): ");
    String firstToken = in.next();
    String restOfSentence = in.nextLine();
    String sentence = firstToken + restOfSentence;

    //phone number
    System.out.print(" Enter the phone number (###) ###-####: ");
    String phoneNum = in.next();
    String restOfNum = in.nextLine();
    String sentence2 = phoneNum + restOfNum;

    //Name of book
    System.out.print(" Enter the title of the book: ");
    String bookName = in.next();
    String restOfName = in.nextLine();
    String sentence3 = bookName + restOfName;

    //Date checked out
    System.out.print(" Enter the date checked out (mm/dd/yyyy): ");
    String bookDate = in.next();
    String restOfDate = in.nextLine();
    String sentence4 = bookDate + restOfDate;

    // Days late
    System.out.print("Days late: ");
    in.nextInt();


    // Daily Fine
    System.out.print("Daily fine: ");
    in.nextDouble();

    //daily fine calculation
    fine = 
}

我需要把这些日子过期并乘以每日罚款以获得罚款的总价。我不需要它在屏幕上显示我只是需要它来计算以后我需要它在屏幕上

1 个答案:

答案 0 :(得分:2)

如下:

CALayer* layer = [CALayer layer];
layer.frame = CGRectMake(10, 10, 30, 30);
layer.backgroundColor = [UIColor redColor].CGColor;
layer.cornerRadius = 20/2.0f;
[cell.contentView.layer  addSublayer:layer];
  • 将它们存储在变量中,然后将它们相乘。
  • 使用Scanner#nextLine清除整数和双输入后的新行字符